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

Advertisements