Skip to main content

How to migrate jobs from one Jenkins build server to another

Prachi is a senior DevOps Engineer specializing in designing, implementing and maintaining production web applications on AWS Cloud/Docker.

I recently set-up a new Jenkins server with the latest stable release to check some new plugins and I wanted to find a quick way to migrate jobs from my existing old server to the new one.

My source Jenkins is dockerized and the target one is a standalone build server.

Now there are multiple ways in which this could be achieved.

  1. Use Jenkins Plugin
  2. Use Jenkins CLI
  3. Copy the jobs directory from the source to the target Jenkins server and reload the configuration from disk

Use Jenkins’ Import Job Plugin

Below is a snapshot from the Jenkins plugins page listing the job import plugin. Install the plugin and restart Jenkins, observe if there are any errors during installation and verify if the installation was successful.

how-to-migrate-jobs-from-one-jenkins-build-server-to-another

If the installation went fine, you should see below plugin configuration section in 'Manage Jenkins'.

Go to Manage Jenkins --> Configure System --> Job Import Plugin

Add the remote source server details.

how-to-migrate-jobs-from-one-jenkins-build-server-to-another

This is an important step. Make sure your user is set to import the jobs with the right permissions.

Also, on the source server, it is recommended that the ‘Authenticated Users’ have at least read/discover/workspace permissions for the jobs.

Scroll to Continue
how-to-migrate-jobs-from-one-jenkins-build-server-to-another

If the plugin installation went well and Jenkins is restarted, the plugin is displayed on the left pane as below

how-to-migrate-jobs-from-one-jenkins-build-server-to-another

Open the above link and notice the options below. If the plugin configuration went well in above steps, the remote Jenkins server (source server) is automatically displayed in the drop-down list. If not, you may want to revisit the URL/credentials section above again to check the issue.

You can fire the query and wait for a couple of minutes for the results to be displayed.

how-to-migrate-jobs-from-one-jenkins-build-server-to-another

Here I have all my jobs enlisted in the query results. I chose to import the jobs and install the plugins as well.

how-to-migrate-jobs-from-one-jenkins-build-server-to-another
how-to-migrate-jobs-from-one-jenkins-build-server-to-another
how-to-migrate-jobs-from-one-jenkins-build-server-to-another

This successfully copies the jobs and plugin configurations, however if you want to migrate your workspace data, that needs to be copied to the respective workspace location from the source to the target.

Else you’re good to go.

We’ll continue to explore the other methods ahead…

Related Articles