CyberKeeda In Social Media

How to export and import Jenkins job.

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.

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.

26 comments:

  1. 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

    ReplyDelete
  2. Ask 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

    ReplyDelete
  3. Titles 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

    ReplyDelete
  4. Every 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

    ReplyDelete
  5. I’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
  6. It's rare all around educated individuals in this specific point, yet you sound like you hear what you're saying! Much obliged
    earthcycle

    ReplyDelete
  7. Very nice article. I enjoyed reading your post. very nice share. I want to twit this to my followers. Thanks !. good morning messages for him

    ReplyDelete
  8. Thanks for sharing this article. I think You put a great deal of exertion to make this article. I like your work. Unique Dofollow Backlinks

    ReplyDelete
  9. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! Shipping Container

    ReplyDelete
  10. Writing in all Caps, utilizing unnecessary interjection focuses, or adding abbreviations and contractions will decrease the believability of the job posting and possibly bring about job cancellation by the facilitating job board. https://europa-road.eu/hu/foldmunkagep-szallitas-debrecen.php

    ReplyDelete
  11. That depends upon your preferences and the size of the family. If you are single or have a small family, an apartment is a better choice for you. Plus, apartments are quick to flip if you decide to sell them and gain profit.

    ReplyDelete

Designed By Jackuna