Skip to content

Instantly share code, notes, and snippets.

@dnozay
Created January 22, 2015 01:34
Show Gist options
  • Save dnozay/df73a74d983bcd15011f to your computer and use it in GitHub Desktop.
Save dnozay/df73a74d983bcd15011f to your computer and use it in GitHub Desktop.
build-flow-plugin, change existing builds' displayName to include the git branch's name where applicable.
// for all builds from build-flow-plugin whose parameters include a GIT_BRANCH paramater,
// change the displayName to include branch and build number
import com.cloudbees.plugins.flow.*;
jobs = Jenkins.instance.getAllItems(BuildFlow);
jobs.each { it ->
it.builds.each { b ->
GIT_BRANCH = b.envVars['GIT_BRANCH']
( GIT_BRANCH =~ /(?:refs\/remotes\/)?(.+)/ ).each { full,branch ->
b.displayName = branch + ' (#' + b.number + ')'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment