Created
January 10, 2018 12:29
-
-
Save vonschnappi/804ab70bddd82fd163998392c61effb1 to your computer and use it in GitHub Desktop.
Getting the commit message when running a Jenkins pipeline job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit = sh(returnStdout: true, script: 'git log -1 --oneline').trim() | |
String commitMsg = "" | |
List commitMsgPre = commit.split(" ") | |
for(int i=1; i<commitMsgPre.size(); i++){ | |
commitMsg += commitMsgPre.getAt(i) + " " | |
} |
(git log -1 --pretty=%B)
Many thanks for this snippet! But everything after
commit = ...
can be replaced by the one line
commitMsg = commit.substring( commit.indexOf(' ') ).trim()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git log -1 --oneline