Skip to content

Instantly share code, notes, and snippets.

@camilb
Forked from fabito/exportShortGitCommit.groovy
Created September 13, 2016 20:03
Show Gist options
  • Save camilb/ecab1e93b639ba1d82bd5fc983376d45 to your computer and use it in GitHub Desktop.
Save camilb/ecab1e93b639ba1d82bd5fc983376d45 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