Can a Jenkins job set the description build upon starting the build
I am familiar with the Description Setter plugin (https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin), but it only kicks in as a post-build action. I have some very long testing builds and I would like to set the build description right on the start – either as a pre-build or as a build step.
3 Solutions collect form web for “Can a Jenkins job set the description build upon starting the build”
Use pre-scm-build step and Conditional Build Step plugins. In global configuration, find “Conditional Build step” section, and select “any builder” (or something similar). This will allow the plugin to use any build or post-build step.
Then in the job configuration, under Build Environment, use “Run buildstep before SCM runs”, and select Conditional Build Step. Leave the condition to “always”, and select “Description Setter”.
FWIW, in my environment with latest plugins, I can execute “Description Setter” from pre-SCM step without the need for Conditional Build step.
Since my build is submitted from a Python script, I added a kludge in the script:
1. Wait until it starts executing and find its build ID in the job (I can uniquely identify my build by the build parameters that were used)
2. Having the job name and the build number, use the Jenkins CLI (jar file) to set the description.
Admittedly, the solution proposed by Slav is more elegant, but I have not gotten around to test it…Once I do, I will report here.
You can also add a groovy build step (which should be the first step), that will use the build parameters, like this:
/* Get System name, version, user name */ def system = build.getEnvironment(listener).get('system') def version = build.getEnvironment(listener).get('system_version') def user = build.getEnvironment(listener).get('USERNAME') /* Build description with params and send description to currentbuild */ def description = "$system / $version / $user" currentBuild.setDescription(description)