How can I set Jenkins build description while triggering build via curl? How can I set Jenkins build description while triggering build via curl? curl curl

How can I set Jenkins build description while triggering build via curl?


You can always have a variable and pass the build description into the variable on the initial invocation. Then at the end of your build, output the variable to console and catch with Description Setter plugin.

Edit to clarify:

  • Install Description Setter plugin.
  • In the Job Configuration, configure a String parameter, call it "MyDescription", leave defaults blank.
  • Somewhere in the build steps, either "Execute Shell" or "Execute Windows Batch Command" type echo Desc: $MyDescription or echo Desc: %MyDescription%, depending on your OS.
  • In the Post-Build steps, select "Set Build Description".
    • Set Regular expression as ^Desc: (.*)
    • Set Description as \1
  • From command line trigger by:

curl -v -X POST --data-urlencode "MyDescription=This is my desc" "http://[myServer]/job/[jobName]/buildWithParameters"
(that above is one line)


I had the same need - set the build description as soon as the build starts.
Note that the Build Description Setter plugin is activated as a post-build action which is too late for me.
The way I solved it is by a minor change to the job configuration and a Python script (but can be in any language):

  • Add a UUID parameter in the job configuration
  • Created a script to submit & set description

The script does as follows:

  1. When submitting a build, generate a uuid value (unique, right?) and populate the UUID parameter
  2. Poll the Jenkins job (get its JSON via REST API), loop on all the running builds, find mine (via the known value of UUID). Limit the polling by a timeout, so we don't hang forever
  3. Use the Jenkins Java CLI to set the description (command 'set-build-description')

Works all the time, except when the build is queued (no free executors are available) and the timeout set above expires - there's nothing I can do.


For those interested in using the Jenkins UI, I'm trying:

  1. https://wiki.jenkins-ci.org/display/JENKINS/Build+Name+Setter+Plugin
  2. https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin

The Postbuild plugin is much more powerful, but requires Groovy tinkering and perms.