How to restore jobs in Jenkins?
In the docs it says that all you have to do is copy the files or folders. But when I do that and then try to restore by restarting the service and using the GUI Manage Jenkins > Reload Configuration from Disk (btw, is there a way to do this programatically?), only the credentials are restored (they come from credentials.xml which I also copied). No jobs are listed. Any ideas? Edit: I created a directory /var/lib/jenkins/jobs/myjob and inside it I dropped the "config.xml" file. That file used to be in the previous instance of my server, on the same location. I also dropped the old "credentials.xml" into /var/lib/jenkins. That worked fine, I can see the credentials in the web interface.
To restore jobs in Jenkins, you just need to copy
jobs/ folder into new Jenkins HOME folder (only
config.xml files is enough) and make sure you’ve all necessary plugins (in Linux it’s
For Jenkins root configuration, you need to copy
config.xml from the main HOME directory (e.g.
/var/lib/jenkins/config.xml). All other XML files are just site-wide and plugin configuration files (which may be copied as well).
For more details, check the following Jenkins directory structure:
JENKINS_HOME +- config.xml (jenkins root configuration) +- *.xml (other site-wide configuration files) +- userContent (files in this directory will be served under your http://server/userContent/) +- fingerprints (stores fingerprint records) +- plugins (stores plugins) +- workspace (working directory for the version control system) +- [JOBNAME] (sub directory for each job) +- jobs +- [JOBNAME] (sub directory for each job) +- config.xml (job configuration file) +- latest (symbolic link to the last successful build) +- builds +- [BUILD_ID] (for each build) +- build.xml (build result summary) +- log (log file) +- changelog.xml (change log)
To reload configuration from the disk, use Reload Configuration from Disk option in Manage Jenkins. From Jenkins CLI, try
reload-configuration command to discard all the loaded data in memory and reload everything from file system.
I deployed the jobs (and plugins and credentials) using the deploy user and forgot to set the ownership to
I realized this by reading the Jenkins logs at
/var/log/jenkins/jenkins.log, there were some “Permission denied” messages.
If you want to copy jobs from other jenkins,
Just copy the $JENKINS_HOME/jobs//config.xml to your new $JENKINS_HOME/jobs, and then reload configuration from disk.
I think from the above answers that you didn’t copy the configuration files for the individual jobs. The JENKINS_HOME directory is laid out like this:
$JENKINS_HOME contains system level configuration files such as the Jenkins master config.xml and the credentials.xml
$JENKINS_HOME/jobs contains all the individual job configuration and build data in a separate subdirectory for each job, e.g. for the job “myjob” you’ll have $JENKINS_HOME/jobs/myjob/config.xml plus other files that store the data for individual builds.
So if you want to restore the system configuration and all the jobs without the build history, you’ll need to copy:
$JENKINS_HOME/jobs/*/config.xml (using Antglob notation, ** denotes all subdirectories under $JENKINS_HOME/jobs)
You’ll also need $JENKINS_HOME/plugins/* if you installed any extra plugins.
If you want to restore all the build history, copy $JENKINS_HOME/jobs/* instead of just the config.xml files.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- PES Matches, Skills & News