Jenkins

Copy Jobs between Jenkin servers


There is a command line to tool for copying Jobs between servers .To do that ,download the jenkincli.jar from Jenkins ->Manage Jenkin -Jenkin Cli.

Now lets go the command line where your jenkin cli downloaded and run the below command ,

java -jar jenkins-cli.jar -s https://server1.com/ copy-job SRC DST
Copies a job.

 SRC : Name of the job to copy
 DST : Name of the new job to be created.


Ex : java -jar jenkins-cli.jar 
-s https://server1.com/ copyjob https://server1.com/job/job1/ https://server2/job/job2

Copying job1 from server 1 to server 2 with name of Job2

Export Jobs

java -jar jenkins-cli.jar -s “https://<server.com&gt;.com/” -auth username:<token/password> get-job <job name> > myjob.xml

Import Jobs

java -jar jenkins-cli.jar -s “https://<server1>.com/” -auth <username>:<LDAP password> create-job test-job < config.xml

If password is not working with -auth command then use Token .

Click the username in the right corner on small drop down box –>configure – >Generate Token

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.