Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ygorth/44b753468814ac41f20b30944f33d3d1 to your computer and use it in GitHub Desktop.
Save ygorth/44b753468814ac41f20b30944f33d3d1 to your computer and use it in GitHub Desktop.
Exporting short git commit sha1 hash in Jenkins through System Groovy Script build step
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