Jenkins needs some disk space to perform builds and keep archives. You can check this location from the configuration screen of Jenkins.
By default, this is set to
~/.jenkins, but you can change this in one of the following ways:
See the container specific documentation collection for more about how to do this for your container.
You can change this location after you've used Jenkins for a while, too. To do this, stop Jenkins completely, move the contents from old JENKINS_HOME to the new home, set the new JENKINS_HOME, and restart Jenkins.
JENKINS_HOME has a fairly obvious directory structure that looks like the following:
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)
All the settings, build logs, artifact archives are stored under the JENKINS_HOME directory. Simply archive this directory to make a back up. Similarly, restoring the data is just replacing the contents of the JENKINS_HOME directory from a back up.
Back ups can be taken without stopping the server, but when you restore, please do stop the server.
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 configuration from the disk.
Replacing spaces in job names with underscores
$ rename 's/\s/_/g' *
Sometimes you want to remove a job from Jenkins but do so in such a way that you can resurrect it later, if the need arises. You can do this by going to $JENKINS_HOME and create an archive of the job directory. The following command illustrates how to archive a job 'xyz' and remove it.
$ cd $JENKINS_HOME/jobs $ tar czf xyz.tgz xyz // go to Jenkins GUI "Manage Jenkins" page and "Reload Configuration from Disk"
As long as you are not building the xyz project while you create an archive, you can do this operation without taking Jenkins offline.
Useful for trouble-shooting, diagnostics or batch updates of jobs Jenkins provides a script console which gives you access to all Jenkins internals.
These scripts are written in Groovy and you'll find some samples of them in this page.
where [command] can be
reloadto reload the configuration