We have a big RAILS project and we are following Github flow to drive our development process. I looked through all the available plugins but could not find anything that customizes the "Build executor status" part of the Jenkins home page.
I wanted to put the name of the git branch instead of job name and executor number since the former makes more sense in our case. Has anybody done this?
You can use the Build Name Setter Plugin to change the name based on available Tokens. I'm not sure if a TOKEN exists for your Git branch name, but if all else fails, you can use a shell script build step and write it to a property file, and then use the macro: ${PROPFILE,..}, e.g.:
#${BUILD_NUMBER}_${PROPFILE,file="parameters.properties",property="BUILD_TYPE"}
Alternatively, you can use the Description Setter Plugin to change the build description (that also appears in the Build Executor status) based on the build output. Again, you can use the same trick and use a shell script to print out the branch name in the build output, and use a regex to parse it out of your build log.
A small limitation: either of this will only update the name/description after the job completes, so for long-running jobs, it's not immediately visible. But for short ones, and for audit purposes, this works well.
[EDIT] Some time later, I started using the EnvInject plugin, which adds my build parameters to the environment early enough for the Build Name Setter Plugin to use them.
This has the advantage of setting the build name immediately.
Also, you can get the Git branch with ${GIT_BRANCH}. Here's the doc for it:
${GIT_BRANCH}
Expands to the name of the branch that was built.
Parameters:
all
If specified, all the branches that point to the given commit is listed.
By default, the token expands to just one of them.
fullName
If specified, this token expands to the full branch name, such as 'origin/master'.
Otherwise, it only expands to the short name, such as 'master'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With