Set Jenkins build display name with Groovy

On the Xtext’s Jenkins instance we have some parametrized jobs that are used for the different projects that are built on Jenkins (Xtext, Xpand, MWE). For example, the simrel-tests job does some health checks on the resulting p2 repositories.

The problem was that it was not obvious for which job name parameter the build was executed. On first sight you only see the build number, and then you have to look in each individual build to identify which parameter was used:

screenshot 15

With the help of a Groovy script using the Jenkins Groovy Plugin we can change the display name of a build:

build name changed

Also on the Dashboard page it becomes clear for which parameter the last build was run:

screenshot 17.png

To do this, add a build step “Execute system Groovy script” and access the job’s environment variables with build.properties.environment.toString(). Then set a new display name by assigning a new value to build.displayName. That’s all.

groovy command

Advertisements