Where does Jenkins store configuration files for the jobs it runs?

Jenkins

Jenkins Problem Overview


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.

Jenkins Solutions


Solution 1 - Jenkins

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)

Solution 2 - Jenkins

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

Solution 3 - Jenkins

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

Solution 4 - Jenkins

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

Solution 5 - Jenkins

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

Solution 6 - Jenkins

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 ....*

Solution 7 - Jenkins

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

Solution 8 - Jenkins

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwandersoView Question on Stackoverflow
Solution 1 - JenkinsMike ChristiansonView Answer on Stackoverflow
Solution 2 - JenkinsautomatixView Answer on Stackoverflow
Solution 3 - JenkinsHlungView Answer on Stackoverflow
Solution 4 - JenkinsADPView Answer on Stackoverflow
Solution 5 - JenkinsBusiness TomcatView Answer on Stackoverflow
Solution 6 - JenkinsPrasad MCNView Answer on Stackoverflow
Solution 7 - JenkinsFaheem ShahView Answer on Stackoverflow
Solution 8 - JenkinsMahesh Bhat MView Answer on Stackoverflow