Skip to content

Commit 8e222fb

Browse files
authored
feat: add approval to oras and quiet git output (#84)
* feat: add approval to oras and quiet git output * feat: git output * feat: add service name in front of intention file
1 parent 399d885 commit 8e222fb

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pipelines/app-maven/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ pipeline {
5656
env.GITHUB_USER = "${params.githubUser}"
5757
env.GITHUB_TOKEN = "${params.githubToken}"
5858
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[var: env.GITHUB_TOKEN, password: GITHUB_TOKEN]]]) {
59-
sh 'git clone -q --branch ${GIT_BRANCH} https://${GITHUB_USER}:${GITHUB_TOKEN}@${GIT_REPO} app'
59+
sh 'git config --global advice.detachedHead false ; git clone -q --branch ${GIT_BRANCH} https://${GITHUB_USER}:${GITHUB_TOKEN}@${GIT_REPO} app'
6060
if (DOWNLOAD_TYPE.toUpperCase().trim() == 'GITHUB') {
6161
sh 'cd downloads ; curl -LO "${DOWNLOAD_URL}" -H "Authorization: token ${GITHUB_TOKEN}"'
6262
}
6363
}
6464
} else {
65-
sh 'git clone -q --branch ${GIT_BRANCH} https://${GIT_REPO} app'
65+
sh 'git config --global advice.detachedHead false ; git clone -q --branch ${GIT_BRANCH} https://${GIT_REPO} app'
6666
if (DOWNLOAD_TYPE.toUpperCase().trim() == 'GITHUB') {
6767
sh 'cd downloads ; curl -LO ${DOWNLOAD_URL}'
6868
}

pipelines/app-oras/Jenkinsfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pipeline {
125125
GIT_CREDS_USR = GIT_CREDS_USR.replaceFirst('@', '%40')
126126
CONFIG_ROLE_ID = credentials('knox-jenkins-jenkins-apps-prod-role-id')
127127
AUTHFILE = "auth.json"
128-
CAUSE_USER_ID = "${params.userId != null && params.userId != "" ? params.userId : "github@internal"}"
128+
DEPLOYMENT_APPROVER = "${params.deploymentApprover != null && params.deploymentApprover != "" ? params.deploymentApprover : "github@internal"}"
129129
INTENTION_ID = "${params.intentionId}"
130130
DOWNLOAD_URL = "${params.downloadUrl}"
131131
DOWNLOAD_TYPE =" ${params.downloadType}"
@@ -137,7 +137,7 @@ pipeline {
137137
try {
138138
echo "Deploy to ${env.ENV_SHORT} environment"
139139
env.ENV_LONG = JenkinsUtil.convertShortEnvToLong("${params.envShort}")
140-
intention = new BrokerIntention(readJSON(file: "app/.jenkins/deployment-intention.json"))
140+
intention = new BrokerIntention(readJSON(file: "app/.jenkins/${env.COMPONENT}-deployment-intention.json"))
141141
if (params.envShort == 'dev') {
142142
env.PODMAN_ANSIBLE_INVENTORY_PATH = params.devInventoryPath
143143
} else if (params.envShort == 'test') {
@@ -146,7 +146,7 @@ pipeline {
146146
env.PODMAN_ANSIBLE_INVENTORY_PATH = params.prodInventoryPath
147147
}
148148
intention.setEventDetails(
149-
userName: env.CAUSE_USER_ID,
149+
userName: env.DEPLOYMENT_APPROVER,
150150
url: env.BUILD_URL,
151151
provider: env.EVENT_PROVIDER,
152152
environment: env.ENV_LONG,
@@ -194,7 +194,7 @@ pipeline {
194194
-v \$(pwd)/downloads:/ansible/downloads \
195195
-e PODMAN_* -e ACTION_TOKEN_* -e COMPONENT*",
196196
command: 'ansible-playbook -i inventory/${PODMAN_ANSIBLE_INVENTORY_PATH} \
197-
app/playbooks/playbook.yaml -e "env_vars=dev" -e "proxy_env=dev"')
197+
app/playbooks/playbook.yaml -e "env_vars=${ENV_SHORT}" -e "proxy_env=${ENV_SHORT}"')
198198
podman.logout(authfile: "${env.AUTHFILE}")
199199
intention.endAction("install")
200200
vault.revokeToken()

pipelines/app/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ pipeline {
4747
env.GITHUB_USER = "${params.githubUser}"
4848
env.GITHUB_TOKEN = "${params.githubToken}"
4949
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[var: env.GITHUB_TOKEN, password: GITHUB_TOKEN]]]) {
50-
sh 'git clone --branch ${GIT_BRANCH} https://${GITHUB_USER}:${GITHUB_TOKEN}@${GIT_REPO} app'
50+
sh 'git config --global advice.detachedHead false ; git clone --branch ${GIT_BRANCH} https://${GITHUB_USER}:${GITHUB_TOKEN}@${GIT_REPO} app'
5151
if (DOWNLOAD_TYPE.toUpperCase().trim() == 'GITHUB') {
5252
sh 'cd downloads ; curl -LO "${DOWNLOAD_URL}" -H "Authorization: token ${GITHUB_TOKEN}"'
5353
}
5454
}
5555
} else {
56-
sh 'git clone --branch ${GIT_BRANCH} https://${GIT_REPO} app'
56+
sh 'git config --global advice.detachedHead false ; git clone --branch ${GIT_BRANCH} https://${GIT_REPO} app'
5757
if (DOWNLOAD_TYPE.toUpperCase().trim() == 'GITHUB') {
5858
sh 'cd downloads ; curl -LO ${DOWNLOAD_URL}'
5959
}

0 commit comments

Comments
 (0)