-
-
Save utopius/01bfae7927d85dd0815214642b79d626 to your computer and use it in GitHub Desktop.
Exporting short git commit sha1 hash in Jenkins through System Groovy Script build step
This file contains hidden or 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
| import hudson.model.* | |
| def env = build.getEnvironment() | |
| def gitCommit = env['GIT_COMMIT'] | |
| def shortGitCommit = gitCommit[0..6] | |
| def pa = new ParametersAction([ | |
| new StringParameterValue("SHORT_GIT_COMMIT", shortGitCommit) | |
| ]) | |
| // add variable to current job | |
| build.addAction(pa) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment