Skip to content

Commit 960779c

Browse files
authored
Use standard git log command for short commit sha
- Long-lived repositories may need more than 6 leading characters to be unique. - Use a standard git command to cover all use cases.
1 parent 094fa9f commit 960779c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

pipeline-examples/gitcommit/gitcommit.groovy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22
// checked out your sources on the agent. A 'git' executable
33
// must be available.
44
// Most typical, if you're not cloning into a sub directory
5-
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
6-
// short SHA, possibly better for chat notifications, etc.
7-
shortCommit = gitCommit.take(6)
5+
shortCommit = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()

0 commit comments

Comments
 (0)