Skip to content

Commit

Permalink
Use standard git log command for short commit sha
Browse files Browse the repository at this point in the history
- Long-lived repositories may need more than 6 leading characters to be unique. 
- Use a standard git command to cover all use cases.
  • Loading branch information
julie-ng authored Sep 11, 2017
1 parent 094fa9f commit 960779c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions pipeline-examples/gitcommit/gitcommit.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
// checked out your sources on the agent. A 'git' executable
// must be available.
// Most typical, if you're not cloning into a sub directory
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
// short SHA, possibly better for chat notifications, etc.
shortCommit = gitCommit.take(6)
shortCommit = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()

0 comments on commit 960779c

Please sign in to comment.