Advance Selenium

Basic guide to Import and export jobs in jenkins and Selenium

Import and export jobs in Jenkins

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.

 

author-avatar

About Mukesh Otwani

I am Mukesh Otwani working professional in a beautiful city Bangalore India. I completed by BE from RGPV university Bhopal. I have passion towards automation testing since couple of years I started with Selenium then I got chance to work with other tools like Maven, Ant, Git, GitHub, Jenkins, Sikuli, Selenium Builder etc.

14 thoughts on “Basic guide to Import and export jobs in jenkins and Selenium

  1. sarah says:

    Do you have more article about Jenkins CLI? i am looking to export the build status to CSV

    1. Hi Sarah,

      There are more videos on Jenkins CLI in pipeline. I’ll post them soon, please stay tuned…:)

  2. Pranoy says:

    Nice article!

  3. samba says:

    Hi Mukesh Otwani,

    I am getting the following error while exporting
    ERROR: anonymous is missing the Overall/Read permission

    1. Hi Samba,

      Are you doing jobs import between different verions of Jenkins?

  4. Priyanshi Ahuja says:

    Please suggest me, Which is good approach to design Framework. Data Driven or Hybrid … Currently I am learning Selenium Tutorials online ….. But I think i need some training ….

  5. Preetish Kumar Mahato says:

    i am facing problm java -jar jenkins-cli.jar -s http://url-of-server get-job myjob > myjob.xml is not working somewere i am geting wrong.. can u plzs help me mukesh .

    1. Hey Preetish,

      Above is just a syntax have u made the changes like url and other things.

  6. Hadeel says:

    Hi Mukash ,

    I’m facing problems in running my test through Jenkins to a server using chrome driver as the following error keep showing : org.openqa.selenium.WebDriverException: unknown error: unable to discover open pages
    Can you help me in this ?

    1. Hey Hadeel,

      Which version of Selenium you are using. Selenium 3 is released so you can update Selenium and try again.

  7. sahil says:

    Hi Mukesh,

    Could create a video tutorial for Jenkins CLI because i don’t know how to set up CLI and backup all Jobs.

    Thanks
    Sahil

Leave a Reply

Your email address will not be published. Required fields are marked *

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