If you have multiple jenkins instances, there might be a requirement to export an existing jenkins job, that could be further imported into the newer jenkins instance.
We will learn how to do the export/import of jenkins job using jenkins cli.
We will learn how to do the export/import of jenkins job using jenkins cli.
How to Export existing Jenkins job.
- Jenkins Home Page
- Manage Jenkins
- Jenkins CLI.
- Download jenkins-cli.jar
- Click on Jenkins CLI.

Once file "jenkins-cli.jar" file has been downloaded, we are ready to export our Jenkins job, lets do it.
Open your terminal and run the below commands.
Authenticate and List down your jobs to identify the one, which one you want to export, replace "your-jenkins-server-url:your_server_port" from your source jenkins server's url and port.
cyberkeeda@jenkins-master:~$ java -jar jenkins-cli.jar -s "http://your-jenkins-server-url:your_server_port" -auth UserName:Password list-jobs djpass-ansible djpass-docker-app docker ps
Now, from above enlisted jobs i want to export the one named as "djpass-docker-app".
Run the below command and replace the highlighted one by yours.
cyberkeeda@jenkins-master:~$ java -jar jenkins-cli.jar -s "http://your-jenkins-server-url:your_server_port" -auth UserName:Password get-job djpass-docker-app > djpass-docker-app.xml
We have successfully exported our jenkins job named as "djpass-docker-app" as an xml file named as "djpass-docker-app.xml"
How to import Jenkins job to different Jenkins server.
- Go to your new jenkins server dashboard, where you want to import.
- Follow the same above steps to download the jenkins-cli.jar file.
- Ensure you are ready with "jenkins-cli.jar" and your exported jenkins job XML file with you.
Now run the below command to import your jenkins job xml file to new jenkins server.
Note : Replace the highlighted one by yours.
Preview:
cyberkeeda@jenkins-slave:~$ java -jar jenkins-cli.jar -s "http://your-Newjenkins-server-url:your_server_port" -auth UserName:Password create-job new-djpass-docker-app < djpass-docker-app.xml
Hoah !!! Thats it, check your dashboard to verify the same.
Nice blog!! I hope you will share more info like this. I will use this for my studies and research.
ReplyDeleteDevOps Training in Chennai
DevOps foundation certification
DevOps certification
AWS Training in Chennai
Cloud Computing Training in Chennai
Data Science Training in Chennai
DevOps Training in Anna Nagar
DevOps Training in Vadapalani
DevOps Training in Guindy
DevOps Training in Thiruvanmiyur
Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles Python course
ReplyDeleteAsk relatives and friends about jobs where they work. Ask every relative and friend you have now or have ever had about vacancies they may know about where they work, or where anyone else works.Hr recruitment Companies in India
ReplyDeleteTitles should be industry-specific and familiar to job seekers since they will use keyword search for positions according to standard job titles. The Job Title field is not the field to market the job posting (like with a classified ad).How to Make cover letter
ReplyDeleteEvery job contributes to that career in some manner, even if the job offers nothing new or challenging and confirms that a person is ready to find new employment or a new occupation. ashamed of being unemployed
ReplyDeleteI read that Post and got it fine and informative. https://europa-road.eu/hu/alacsony-gepszallitas-arak.php
ReplyDeleteI’ve read some good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website. Europa-Road targonca szállítás Debrecen
ReplyDelete