Skip to content

Commit b729936

Browse files
author
Vaughn Dice
committed
ref(Jenkinsfile): remove shell output hack
ref deis/workflow-cli#203
1 parent 598a9ae commit b729936

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

Jenkinsfile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def sh = { String cmd ->
1+
def sh = { cmd ->
22
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
33
sh cmd
44
}
@@ -29,18 +29,13 @@ def git_branch = ''
2929
stage 'Go & Git Info'
3030
node('linux') {
3131
checkout scm
32-
// HACK: Recommended approach for getting command output is writing to and then reading a file.
33-
sh 'mkdir -p tmp'
34-
sh 'git describe --all > tmp/GIT_BRANCH'
35-
sh 'git rev-parse HEAD > tmp/GIT_COMMIT'
36-
git_branch = readFile('tmp/GIT_BRANCH').trim()
37-
git_commit = readFile('tmp/GIT_COMMIT').trim()
32+
33+
git_branch = sh(returnStdout: true, script: 'git describe --all').trim()
34+
git_commit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
3835

3936
if (git_branch != "remotes/origin/master") {
4037
// Determine actual PR commit, if necessary
41-
sh 'git rev-parse HEAD | git log --pretty=%P -n 1 --date-order > tmp/MERGE_COMMIT_PARENTS'
42-
sh 'cat tmp/MERGE_COMMIT_PARENTS'
43-
merge_commit_parents = readFile('tmp/MERGE_COMMIT_PARENTS').trim()
38+
merge_commit_parents= sh(returnStdout: true, script: 'git rev-parse HEAD | git log --pretty=%P -n 1 --date-order').trim()
4439
if (merge_commit_parents.length() > 40) {
4540
echo 'More than one merge commit parent signifies that the merge commit is not the PR commit'
4641
echo "Changing git_commit from '${git_commit}' to '${merge_commit_parents.take(40)}'"

0 commit comments

Comments
 (0)