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.

  • Cordova - Install AdMob Plugin on Android Failed (Mac)
  • Jenkins git plugin and branches
  • In Jenkins, View Job Filters plugin, how do you use a Regular Expression Job Filter on SCM Configuration to filter on a branch name?
  • List of Source Control Systems with Visual Studio Plugins
  • Disable “Accept Merge Request” button based on GitLab CI status and/or SonarQube results
  • How to save required plugins settings and ask other user to install plugins, when opening the project?
  • Installing a rails plugin from a Git repository
  • Git: Maintaining third-party modules consisting of multiple directories
  • 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.