简体   繁体   English

如何保存Jenkins配置?

[英]How to save Jenkins configuration?

有什么方法可以在Git或其他任何地方保存管道配置或项目配置,以便当我的Jenkins机器崩溃时,我可以在新的Jenkins实例中迁移保存的配置?

Hi you can write the pipeline script in file and publish that file into the git. 嗨,您可以在文件中编写管道脚本,然后将该文件发布到git中。

After that just create the pipeline job in the jenkins and use Pipeline script from SCM option for pipeline script. 之后,只需在詹金斯中创建管道作业,然后将Pipeline script from SCM选项中的管道脚本用于管道脚本即可。

The other option is take backup of Jenkins home directory to external hard disk(keep project workspace outside the jenkins home to reduce backup size). 另一个选择是将Jenkins主目录备份到外部硬盘(将项目工作区保留在Jenkins主目录之外以减小备份大小)。

All your jobs is stored in config.xml files inside $JENKINS_HOME/jobs/<path_to_your_job> folders. 您的所有作业都存储在$JENKINS_HOME/jobs/<path_to_your_job>文件夹中的config.xml文件中。 So, you can just backup these config.xml files (or you can backup all Jenkins configuration by saving full $JENKINS_HOME folder). 因此,您可以仅备份这些config.xml文件(或者可以通过保存完整的$JENKINS_HOME文件夹来备份所有Jenkins配置)。

I would ( as a start ) get yourself - https://wiki.jenkins.io/display/JENKINS/JobConfigHistory+Plugin which keeps history of all Changes made to Jobs , System config etc - has saved me multiple times. 我会(作为一个开始)让自己-https: //wiki.jenkins.io/display/JENKINS/JobConfigHistory+Plugin保留对Jobs所做的所有更改,系统配置等的历史记录-已为我节省了很多时间。

Also , you could setup a cron job outside Jenkins to git push your Job config. 另外,您可以在Jenkins外部设置cron作业以git push您的Job config。

I setup to push the Jobs folder content ( including Build history - but you could exclude that - Correctly ignore all files recursively under a specific folder except for a specific file type ref ) . 我设置为推送Jobs文件夹的内容(包括“构建历史记录-但您可以排除- 正确地递归地忽略特定文件夹下的所有文件,除了特定文件类型 ref)”。

My script ( i had SSH stuff previously setup ) 我的脚本(我之前设置了SSH东西)

cd /this/that/other/jenkins_data/jobs/
NOW=$(date +"%m-%d-%Y-%r")
git add .
git commit -m "Jenkins Backup $NOW"
git push -u origin jenkins-backup

This way gives me piece of mind , I have RSYNC to another box and I also have a Backup plugin running too... ( i was stung once - not again! ) 这样让我有了主意,我将RSYNC同步到另一个机器上,并且我也有一个Backup插件正在运行...(我被刺伤了一次-再也没有!)

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM