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.

  • Jenkins + Cmake + JIRA = CI of multiple interdependent projects?
  • Jenkins CI Pipeline Scripts not permitted to use method groovy.lang.GroovyObject
  • Jenkins Pipeline sh display name/label
  • Jenkins And NodeJS Plugin - Permission Denied Error=13
  • Jenkins Git Plugin: How to build specific tag?
  • groovy.lang.MissingPropertyException: No such property: manager for class: Script1
  • Jenkins pipeline MissingMethodException: No signature of method:
  • How do we manually fix “ResourceRules.plist: cannot read resources” error after xcode 6.1 upgrade?
  • How to get a list of installed jenkins plugins with name and version pair?
  • Parsing an XML file within a Jenkins pipeline
  • How to get the jobname from jenkins
  • Create a hudson/jenkins job with a web-form upload
  • 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)
    
    Git Baby is a git and github fan, let's start git clone.