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.

  • Can I import a groovy script from a relative directory from a Jenkinsfile?
  • Docker jenkins container, host key verification failed
  • Kubernetes plugin containers can't connect back to Jenkins
  • hudson.plugins.git.GitSCM.determineRevisionToBuild
  • Setting up jenkins with git by ssh
  • Maven with Jenkins - Update parent pom version of dependency
  • How do I trigger another job from hudson as a pre-build step?
  • Jenkins : Selenium GUI tests are not visible on Windows
  • Jenkins continuous delivery pipeline skip stage based on input
  • How to compile and run a simple java file in jenkins on Windows
  • Git Publisher “target remote name” validation problems, single repo
  • Increase the Jenkins login timeout
  • 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.