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 /var/lib/jenkins/
).
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)
Source: Administering Jenkins - JENKINS_HOME directory
See also: Is there a way to keep Hudson / Jenkins configuration files in source control?
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 jenkins:jenkins
.
I realized this by reading the Jenkins logs at /var/log/jenkins/jenkins.log
, there were some "Permission denied" messages.
In case you mistakenly changed job configuration in your Jenkins service/docker still running ,you can revert the configuration from web GUI using job configuration history plugin
Jenkins -> Job -> Job Config History -> Select radio buttons of correct version And bad version -> Show diffs (xml diff versions) -> select the right version and press 'restore this configuration'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With