Mugen
Mugen

Reputation: 1579

How can I copy the Jenkins build history from one server to another?

We're moving servers to another system. We have setup Jenkins, imported all jobs with the job import plugin.

Next I would like to import the data for each of those jobs. This is what I'm talking about:

Build history of every individual job

Please note that the jobs are distributed across multiple folders and subfolders. How can I copy/move the build history for each of these jobs to the new server?

Upvotes: 2

Views: 4614

Answers (3)

Harshana Kuruppu
Harshana Kuruppu

Reputation: 41

Moving/copying/renaming jobs You can:

  1. Move a job from one installation of Jenkins to another by simply copying the corresponding job directory.
  2. Make a copy of an existing job by making a clone of a job directory by a different name.
  3. Rename an existing job by renaming a directory. Note that if you change a job name you will need to change any other job that tries to call the renamed job.

Those operations can be done even when Jenkins is running. For changes like these to take effect, you have to click "reload config" to force Jenkins to reload the configuration from the disk.

https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins

Upvotes: 0

itso
itso

Reputation: 31

If your old Jenkins server is still up and running you can ssh to it and use rsync to copy over the builds directory for each job to the new server. Replace $JENKINS_HOME and $NEW_SERVER below with your actual values.

for i in $JENKINS_HOME/jobs/*; do
  rsync -az -e ssh ${i}/builds/* $NEW_SERVER:${i}/builds/
done

Upvotes: 3

Near
Near

Reputation: 312

I have just completed the same mirgration minutes ago, lol. You can do it simply by putting the folders in your old server's build path to new one.

The build history locates in the build directory, if you don't know where it is, check the config.xml in your Jenkins folder (AKA $JENKINS_HOME\config.xml) and ctrl+F "buildsDir".

Default build path in Jenkins is ${ITEM_ROOTDIR}/builds, which is inside the jobs folder under $JENKINS_HOME. I personally recommend you to have the history and Jenkins home located in different drives for a better memory management.

So, simply copy the jobs and history to the new build server, put the old jobs under $JENKINS_HOME\jobs and the old build folder in the new build directory (buildsDir).

Noted that there are some files that cannot be copied because there are some pointers such as Last Successful build, lastFailedBuild in the history. Simply skip those files

Hope it helps

Upvotes: 3

Related Questions