Operations 4 min read

Guide to Migrating Jenkins to a New Server

This article provides a step‑by‑step tutorial on preparing the environment, configuring Tomcat, copying Jenkins files, and handling permissions to successfully migrate a Jenkins instance to a new machine or directory.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Guide to Migrating Jenkins to a New Server

Jenkins is widely used in testing, and migrating it becomes necessary due to machine decommission, resource constraints, or task conflicts.

1. Environment preparation

On a new machine install required dependencies such as Tomcat and JDK; multiple independent Jenkins instances can share a machine.

Copy the Tomcat installer to a target directory and edit conf/server.xml to change three ports, ensuring they are free.

Copy jenkins.war into Tomcat's webapps directory.

Configure Tomcat startup scripts:

Step1: give execution permission to shell scripts: chmod +x *.sh Step2: add new Tomcat paths to ~/.bash_profile:

export CATALINA_BASE2=/home/xxxx/software/apache-tomcat-7.0.59
export CATALINA_HOME2=/home/xxxx/software/apache-tomcat-7.0.59

then run source ~/.bash_profile Step3: add the required content to startup.sh and shutdown.sh (content omitted for brevity).

Step4: in catalina.sh set the Jenkins home directory to avoid conflicts with the default ~/.jenkins directory.

Step5: start Jenkins with sh startup.sh.

2. Jenkins migration

After preparing the environment, copy the original Jenkins home directory (including config.xml, jobs, users, workspace, and plugins) to the new location, then restart Jenkins.

Tip: Ensure the copied files belong to the Tomcat user (e.g., chown -R tomcat:tomcat <directory>) to prevent permission issues.

Tip: If startup problems occur, check the log directory for specific errors such as port conflicts.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdAutomationDevOpsTomcatJenkins
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.