Skip to content

Commit da92e75

Browse files
author
Vaughn Dice
authored
Merge pull request #203 from vdice/remove-shell-output-hack
ref(Jenkinsfile): remove shell output hack
2 parents e6d96b7 + 912ad85 commit da92e75

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

Jenkinsfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def getBasePath = { String filepath ->
88
return filepath.substring(0, filename)
99
}
1010

11-
def sh = { String cmd ->
11+
def sh = { cmd ->
1212
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
1313
sh cmd
1414
}
@@ -51,18 +51,12 @@ stage 'Git Info'
5151
node(linux) {
5252
checkout scm
5353

54-
// HACK: Recommended approach for getting command output is writing to and then reading a file.
55-
sh 'mkdir -p tmp'
56-
sh 'git describe --all > tmp/GIT_BRANCH'
57-
sh 'git rev-parse HEAD > tmp/GIT_COMMIT'
58-
git_branch = readFile('tmp/GIT_BRANCH').trim()
59-
git_commit = readFile('tmp/GIT_COMMIT').trim()
54+
git_branch = sh(returnStdout: true, script: 'git describe --all').trim()
55+
git_commit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
6056

6157
if (git_branch != "remotes/origin/master") {
6258
// Determine actual PR commit, if necessary
63-
sh 'git rev-parse HEAD | git log --pretty=%P -n 1 --date-order > tmp/MERGE_COMMIT_PARENTS'
64-
sh 'cat tmp/MERGE_COMMIT_PARENTS'
65-
merge_commit_parents = readFile('tmp/MERGE_COMMIT_PARENTS').trim()
59+
merge_commit_parents= sh(returnStdout: true, script: 'git rev-parse HEAD | git log --pretty=%P -n 1 --date-order').trim()
6660
if (merge_commit_parents.length() > 40) {
6761
echo 'More than one merge commit parent signifies that the merge commit is not the PR commit'
6862
echo "Changing git_commit from '${git_commit}' to '${merge_commit_parents.take(40)}'"

0 commit comments

Comments
 (0)