Skip to content

Commit acb333a

Browse files
author
Vaughn Dice
authored
Merge pull request #44 from vdice/always-pass-down-sdk-params
fix(Jenkinsfile): always pass down SDK_SHA/SDK_GO_REPO
2 parents 397267a + ba0403d commit acb333a

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

Jenkinsfile

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ node('linux') {
4343
}
4444
}
4545

46-
def actual_commit = ''
46+
def git_commit = ''
4747
def git_branch = ''
4848
def go_repo = ''
4949

@@ -58,26 +58,28 @@ node('linux') {
5858

5959
// HACK: Recommended approach for getting command output is writing to and then reading a file.
6060
sh 'mkdir -p tmp'
61-
sh 'go list . > tmp/GO_LIST'
62-
// HACK: Jump hurdle to get at actual PR commit rather than merge commit
63-
sh 'git rev-parse HEAD | git log --pretty=%P -n 1 | cut -c1-40 > tmp/ACTUAL_COMMIT'
6461
sh 'git describe --all > tmp/GIT_BRANCH'
65-
go_list = readFile('tmp/GO_LIST').trim()
66-
actual_commit = readFile('tmp/ACTUAL_COMMIT').trim()
62+
sh 'git rev-parse HEAD > tmp/GIT_COMMIT'
63+
sh 'go list . > tmp/GO_LIST'
6764
git_branch = readFile('tmp/GIT_BRANCH').trim()
68-
// convert 'github.com/deis/controller-sdk-go' to 'github.com/${env.CHANGE_AUTHOR}/controller-sdk-go'
69-
go_repo = go_list.replace('deis', env.CHANGE_AUTHOR)
65+
git_commit = readFile('tmp/GIT_COMMIT').trim()
66+
go_repo = readFile('tmp/GO_LIST').trim()
67+
68+
if (git_branch != "remotes/origin/master") {
69+
// HACK: get actual PR commit (https://github.com/deis/controller-sdk-go/issues/45)
70+
sh 'git rev-parse HEAD | git log --pretty=%P -n 1 | cut -c1-40 > tmp/ACTUAL_COMMIT'
71+
git_commit = readFile('tmp/ACTUAL_COMMIT').trim()
72+
// convert 'github.com/deis/controller-sdk-go' to 'github.com/${env.CHANGE_AUTHOR}/controller-sdk-go'
73+
go_repo = go_repo.replace('deis', env.CHANGE_AUTHOR)
74+
}
7075
}
7176
}
7277

7378
stage 'Trigger workflow-cli pipeline with this repo and sha'
7479

75-
def parameters = []
76-
if (git_branch != "remotes/origin/master") {
77-
echo "Passing down SDK_SHA='${actual_commit}' and SDK_GO_REPO='${go_repo}' to the Deis/workflow-cli job..."
78-
parameters = [
79-
[$class: 'StringParameterValue', name: 'SDK_SHA', value: actual_commit],
80-
[$class: 'StringParameterValue', name: 'SDK_GO_REPO', value: go_repo]]
81-
}
80+
echo "Passing down SDK_SHA='${git_commit}' and SDK_GO_REPO='${go_repo}' to the Deis/workflow-cli job..."
81+
parameters = [
82+
[$class: 'StringParameterValue', name: 'SDK_SHA', value: git_commit],
83+
[$class: 'StringParameterValue', name: 'SDK_GO_REPO', value: go_repo]]
8284

8385
build job: 'Deis/workflow-cli/master', parameters: parameters

0 commit comments

Comments
 (0)