Here is the Groovy script I use, which gets the description from the log. You can modify as required to use an environment variable (I think). Matthew Webber
// This Groovy script must be run using a Jenkins "Execute system Groovy script" build step // A previous step must write a line in the log of the form defined in "pattern" below def currentBuild = Thread.currentThread().executable def pattern = /^set-build-description: (.+)$/ // Parsing 20 most recent lines of the build log log = currentBuild.getLog(20) for (line in log) { match = (line =~ pattern) if (match) { currentBuild.setDescription(match[0][1]) out.println "[set-build-description.groovy] Build description was set to: " + match[0][1] break } } > -----Original Message----- > From: jenkinsci-users@googlegroups.com > [mailto:jenkinsci-users@googlegroups.com] On Behalf Of cscooper > Sent: 04 December 2013 00:09 > To: jenkinsci-users@googlegroups.com > Subject: How can I set the build description from a parameter? > > I've got a parameterized matrix build, one of the parameters is called > "Description" and in the "Prepare an environment for the run" section, under > "Script Content", I have this: > curl -G -s --data-urlencode "Description=$Description" > "http://localhost:8080/job/$JOB_NAME/$BUILD_NUMBER/submitDescription" > this works great to set the description of the build according to the > Description parameter, and do so early on in the build (I'm not as happy > with the plugins that set the description at the end of the build). > > HOWEVER > > when the Matrix part of the job kicks in, this code gets executed again on > my Linux box which chokes because it's only a slave so http://localhost:8080 > doesn't mean anything. > > I thought about actually specifying the IP, so the "submitDescription" would > go to the actual build server, but in the matrix build $JOB_NAME is now > "Job/Matrix=linux" so the URL isn't right anyway. > > AND > > I've also got a Windows slave, and "curl" just completely confuses him. > > I tried writing an "if" statement in the "Script Content" - something like > this: > > if [[ "$NODE_NAME" = "master" ]]; then > curl -G blah blah blah > fi > > but (1) Jenkins wasn't at all happy with that, and (2) even if Jenkins > accepted it, my Windows slave would choke on it. > > * Is there a better way to set the build description from a parameter? > * Is there a way to have Jenkins prepare the environment differently on > different nodes? > * Is there a trick to putting a value in "Script File Path" such that it > runs correctly on both Windows and Linux slaves? > * Is there something clever I can do with a Groovy script here? > > Thanks for any and all advice! > Chris > -- This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message. Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.