127

I'm adding continuous integration to an EC2 project at work using Jenkins. The Jenkins machine itself is kept on an EC2 machine - one that might need to be taken offline and brought back on an entirely different EC2 instance at any point. We have a bunch of Puppet manifests allowing us to easily reinstall the software on the EC2 instance, but custom configuration files, like the ones for the jobs I create in Jenkins, would be deleted after the move.

Now, if Jenkins stores what jobs are to be run on it in an XML file or set of XML files somewhere, I could set up a system where those files are committed to the version control server, and then downloaded back to a newly-created server as part of the puppet manifest. Does anyone know where these files are stored? I've tried copying /var/lib/jenkins/jobs, but that appears to store the output of Jenkins' jobs, not the input.

d4nyll
  • 11,811
  • 6
  • 54
  • 68
wanderso
  • 1,785
  • 3
  • 13
  • 21

9 Answers9

157

Jenkins stores some of the related builds data like the following:

  • The working directory is stored in the directory {JENKINS_HOME}/workspace/.

    • Each job store its related temporal workspace folder in the directory {JENKINS_HOME}/workspace/{JOBNAME}
  • The configuration for all jobs stored in the directory {JENKINS_HOME}/jobs/.

    • Each job store its related builds data in the directory {JENKINS_HOME}/jobs/{JOBNAME}

    • Each job folder contains:

      • The job configuration file is {JENKINS_HOME}/jobs/{JOBNAME}/config.xml

      • The job builds are stored in {JENKINS_HOME}/jobs/{JOBNAME}/builds/

See the Jenkins documentation for a visual representation and further details.

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)
 +- nodes          (slave configurations)
 +- plugins        (stores plugins)
 +- secrets        (secretes needed when migrating credentials to other servers)
 +- 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)
Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
Mike Christianson
  • 1,927
  • 1
  • 12
  • 7
  • 1
    And how would you download them? – Martin Oct 02 '13 at 09:37
  • 3
    If you don't have access to your jenkins installation folder, you could create a simple jenkins job and run a script that tars all the config files for the jobs: "tar -zcvf jenkins-jobs-configs.tar.gz $(find ${JENKINS_HOME}/jobs -name config.xml -maxdepth 2) ". You could then archive jenkins-jobs-configs.tar.gz – Jakub Czaplicki Feb 02 '15 at 14:19
  • 1
    Note there is also a [Job Configuration History plugin](https://wiki.jenkins-ci.org/display/JENKINS/JobConfigHistory+Plugin) which can let you view your current and previous job configurations, and do so right from the web browser if you prefer/require that over shell access to Jenkins servers. – Neil Apr 27 '15 at 17:39
  • 13
    You can download the config file from a Jenkins node by running: `curl http://:8080/job//config.xml > jenkins_config.xml` – JESii Mar 17 '16 at 14:38
  • Whether its possible to get config.xml when we create jenkins job via pipeline method? – Manigandan Thanigai Arasu May 08 '19 at 09:02
  • can i store these job build infos in a database ? – Youssef Boudaya May 19 '21 at 09:21
32

On Linux one can find the home directory of Jenkins looking for a file, that Jenkins' home contains, e.g.:

$ find / -name "config.xml" | grep "jenkins"
/var/lib/jenkins/config.xml
automatix
  • 14,018
  • 26
  • 105
  • 230
9

Jenkins 1.627, OS X 10.10.5 /Users/Shared/Jenkins/Home/jobs/{project_name}/config.xml

Hlung
  • 13,850
  • 6
  • 71
  • 90
4

The best approach would be to keep your job configurations in a Jenkinsfile that live in source control.

ADP
  • 136
  • 1
  • 6
3

For the sake of completeness: macOS High Sierra, Jenkins 2.x, installation via Homebrew
~/.jenkins/jobs/{project_name}/config.xml

Complete overview about jenkins home: https://wiki.jenkins.io/display/JENKINS/Administering+Jenkins

Business Tomcat
  • 1,021
  • 9
  • 12
1

Am adding few things related to jenkins configuration files storage.

As per my understanding all config file stores in the machine or OS that you have installed jenkins.

The jobs you are going to create in jenkins will be stored in jenkins server and you can find the config.xml etc., here.

After jenkins installation you will find jenkins workspace in server.

*cd>jenkins/jobs/`
cd>jenkins/jobs/$ls
   job1 job2 job3 config.xml ....*
Prasad MCN
  • 19
  • 3
1

Jenkins store configuration files for the jobs in jobs folder at these locations

C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins.jenkins C:\Users<user.name>.jenkins

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 21 '21 at 11:41
1

In ubuntu, if you are running Jenkins on your local machine its usually store job information for the master machine in this directory /var/lib/jenkins/jobs

Farrukh
  • 11
  • 1
0

If you are using windows. you can search for a file config.xml it won't be in the installed folder. I got the file here C:\ProgramData\Jenkins.jenkins