Hello everyone welcomes back once again to Selenium Webdriver tutorial series. Today we will discuss how to Import and export jobs in Jenkins using CLI (Command line interface).
If you are completely new to Jenkins then you must have to visit below post.
Tips for Import and export jobs in jenkins
1- When you have multiple instances of Jenkins and you want to import and export some jobs then you can try below methods.
2- You can backup all Jobs using CLI which is most important
Follow below steps Import and export jobs in jenkins
Export the job
Step 1- Open Jenkins and Go to the job which you want to export.
Copy the name and store somewhere
Click on Manage jenkins options
Step 2- Click on Jenkins CLI which will open CLI window
Step 3- Now download CLI Jar as shown below and save in drive
Notes- We will use some commands which will help us to do our job.
get-job- this will export the job in XML file.
create-job – this will import the job from XML and will create job in Jenkins.
Step 4- Once you have jar ready use below command to export job in XML format.
[pullquote align=”normal”]java -jar jenkins-cli.jar -s http://url-of-server get-job myjob > myjob.xml [/pullquote]
Step 5- Once job exported you can check the job in below location in your local system
C > User > Your UserName > xml which we created
Import the job in Jenkins
Step 6- Now we can use below commands to upload or create new job in jenkins.
[pullquote align=”normal”] java -jar jenkins-cli.jar -s http://url-server create-job newjobname < xml-want-upload.xml [/pullquote]
Step 7- Once you are done check Jenkins and you will get new job ready.
I hope you have enjoyed this article. If you have any doubt then post in our Selenium forum.
Please comment below for any feedback.