Basic guide to Import and export jobs in jenkins and Selenium

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.

Selenium Integration with Jenkins.

Get more information about CLI

 

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

import and export jobs in Jenkins 1

 

Step 2- Click on Jenkins CLI which will open CLI window

import and export jobs in Jenkins 2

 

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.

import and export jobs in Jenkins 3

 

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]

 

import and export jobs in Jenkins 4

 

Step 5-  Once job exported you can check the job in below location in your local system

 

C > User > Your UserName > xml which we createdimport and export jobs in Jenkins 6

 

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]

 

import and export jobs in Jenkins 7

 

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.

 

8 Comments

  1. Priyanshi Ahuja
  2. Preetish Kumar Mahato
  3. Hadeel
  4. sahil