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

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.

265064 次浏览

Jenkins 存储一些相关的构建数据,如下所示:

  • 工作目录存储在目录 {JENKINS_HOME}/workspace/中。

    • Each job store its related 临时工作区文件夹 in the directory {JENKINS_HOME}/workspace/{JOBNAME}
  • The configuration for all jobs stored in the directory {JENKINS_HOME}/jobs/.

    • 每个作业在目录中存储其相关的 建立数据 {JENKINS_HOME}/jobs/{JOBNAME}

    • 每个作业文件夹包含:

      • 作业配置文件{JENKINS_HOME}/jobs/{JOBNAME}/config.xml

      • 增加工作机会存储在 {JENKINS_HOME}/jobs/{JOBNAME}/builds/

有关可视化表示和进一步的细节,请参见 詹金斯的文件

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)

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

我添加了一些与 jenkins 配置文件存储相关的东西。

根据我的理解,所有的配置文件存储在机器或操作系统,您已经安装了 jenkins。

您将在 jenkins 中创建的作业将存储在 jenkins 服务器中,您可以在这里找到 config.xml 等。

在 jenkins 安装之后,您将在服务器中找到 jenkins 工作区。

*cd>jenkins/jobs/`
cd>jenkins/jobs/$ls
job1 job2 job3 config.xml ....*

在 Linux 上,人们可以找到詹金斯的主目录,寻找詹金斯的主目录中包含的文件,例如:

$ find / -name "config.xml" | grep "jenkins"
/var/lib/jenkins/config.xml

For the sake of completeness: MacOS High Sierra,Jenkins 2.x,通过 Homebrew 安装
~/.jenkins/jobs/{project_name}/config.xml

关于詹金斯家的完整概述: https://wiki.jenkins.io/display/JENKINS/Administering+Jenkins

最好的方法是将作业配置保存在源代码控制中的 Jenkins 档案中。

Jenkins 将作业的配置文件存储在这些位置的作业文件夹中

C: Windows System32配置系统配置文件 AppData Local Jenkins.jenkins C: Users < user.name > . jenkins

如果您使用的是 windows.you 可以搜索文件 config.xml 它不会在安装的文件夹中。我得到了这里的文件 C: ProgramData Jenkins.jenkins

在 ubuntu 中,如果您在本地机器上运行 Jenkins,它通常将主机的作业信息存储在这个目录/var/lib/Jenkins/jobs 中