Setting the build description for a jenkins job

If you want to set the build description for a Jenkins job, then follow the below steps.

1. Make sure that the “Description Setter Plugin” installed on the Jenkins server.
2. Go to your Jenkins job configuration page.
3. Go to Post-Build Actions section.
4. On the “Set the build description” section, provide the regular expression to look for it and also the regular expression for failed builds.

Refer the below snippet from my Jenkins job.

setBuildDesc

 

I have given the regex as “project tag number is (\d*)”. So Jenkins will look for this string in my job console output and retrieve the number and use that value as build description. If in case, the job is failed, then it will use “failed” text as the build description.

My Jenkins job sample console output is as given below,


....
....
....
Project has been built successfully.
project tag number is 20180330
job finished Date: Fri Mar 30 03:22:13 EDT 2018
[description-setter] Description set: 20180323
....

The build history looks like below,

buildhistory

Advertisements

Move Jenkins jobs from old server to new server

Follow the below steps to move the Jenkins jobs from one server to an another server.

1. Download the jenkins-cli.jar from your Jenkins server(http://JENKINS.SERVER/jnlpJars/jenkins-cli.jar)

2. Then run the below command to get the job configuration and then move it to a config file. Make sure to update the SERVER NAME, JOB_NAME, USERNAME, PASSWORD accordingly


java -jar jenkins-cli.jar -s http://OLD.JENKINS.SERVER.NAME get-job JOB_NAME --username USERNAME --password PASSWORD > JOB_NAME.xml


3. Finally, run the below command to create the job on the new server.Make sure to update the SERVER NAME, JOB_NAME, USERNAME, PASSWORD accordingly


java -jar jenkins-cli.jar -s http://NEW.JENKINS.SERVER.NAME create-job JOB_NAME --
username USERNAME --password PASSWORD < JOB_NAME.xml