Worried about migrating Jenkins from One Server to another?
Most recently I worked on a project where we had a Jenkins server running on lower configuration and was "dead" slow to support multitasking hence need came up to migrate Jenkins jobs from the current server to a high config server.
Trust me I was worried thinking how do I migrate my "Hundreds" of Jenkins Job from one server to another? Is this possible? Or I will have to create each step manually onto the new server?
Yes, I thought it would be very complicated but after getting a solution I was literary smiling and thinking "Is it that simple?" Will it really work? Sorry, I am QA by blood, so I don't trust it until I do it on my own. I tried doing POC on my own. And yes it was dammed simple. Please follow the below steps to achieve it at your end.
Step 1: Download and Install Jenkins on the server where we want our Jenkins jobs to be migrated having its name as "TargetServer". In case you are not aware of how to do it. Please follow this.
Step 2: Click on Manage Jenkins present at Home Screen on the top left corner as given in the below image, followed by which click on Manage Plugin.
Step 3: Search for the "Job Import" plugin and install it on the "TargetServer".
Step 4: Once the installation is done we need to configure the Plugin. For that click on "Manage Jenkins" followed by that click on "Configure System". Scroll to the "Job Import" section similar to the one shown below.
Step 5: Click on the "Add Remote Jenkins" option. Followed by it enter details of the Source Jenkins server, the one where we want to copy the job from. Details involve entering the Name, URL as well as Login credentials of the Jenkins as shown below. Please note I have not entered Credential as I don't have authentication present for my Jenkins server.
Step 6: After adding the above details click on "Save".
Step 7: From the Dashboard screen of Jenkins on the "TargetServer" click on "Job Import Plugin" as shown below
Step 8: After the above step, we will be able to see the below screen, click on the "Query" button.
Step 9: Once it's done we will be able to see lists of Jobs from the Source Jenkins server. You can choose the one you want to import, as well as we can Install corresponding dependent plugins that are needed for Jobs to be successfully imported.
Step 10: Click on the Import button and Yes we are done. You will be able to see all Jobs that got imported and added to the dashboard screen on the TargetServer.
Bringing it up altogether!!
With the help of "Job Import" plugin, you can easily import Jenkins Jobs from one server to another after following the above simple steps provided both servers are on the same domain. Once jobs are imported depending upon our Target server configuration ( eg: Drives) you need to make changes into the steps of Jenkins jobs and there you go we are good with executing Jenkins Jobs on TargetServer.
Hope this Blog will help you in case you fall into similar need of migrating your Jenkins job from one server to another. Please go ahead and add your experience to the comment session. We can connect on LinkedIn and talk more in case you face any issues. If you enjoyed this post, I’d be very grateful if you’d help it spread it to your connections on Linkedin or other channels.
Thank you!
Automation Test Engineer
1 年while i was doing this process, facing error as unable to read config.xml. how to solve this issue
Certified Senior DevOps Engineer | Driving Scalable, Secure, and Efficient Cloud Solutions | Expertise in CI/CD, Automation, and Infrastructure as Code
2 年Thanks for the article , very useful , I have one thing though , when I migrate to new server the job is getting migrated it fine , but we need build history also to get migrated , is there a way for that ?
Systems Engineer (Remote)
2 年Thank you for your article. Have you tried this from a server running Linux Ubuntu to a server running Windows 2019? Searching for solutions.
DevOps and Cloud Engineer
3 年very useful howto Suraj, thank you!