如何导出/导入 Jenkins 配置? [英] How to export/import the Jenkins configuration?

查看:125
本文介绍了如何导出/导入 Jenkins 配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins CLI 提供导出和导入单个作业的功能,例如:

The Jenkins CLI provides the function to export&import single jobs, e.g.:

java -jar jenkins-cli.jar -s http://foo-jenkins.tld:8080 get-job myjob > myjob.xml
java -jar jenkins-cli.jar -s http://bar-jenkins.tld:8080 create-job newmyjob < myjob.xml

是否也可以/如何备份和恢复配置?

我的意思是整个设置:

  • 系统配置,
  • 全局安全配置,
  • 凭据,
  • 全局工具配置,
  • 插件配置(HTTP 代理配置"和已安装插件列表)
  • 节点
  • 用户
  • 有什么遗漏吗?

一次完成整个设置,或者甚至作为单个备份/恢复过程,例如MozBackup 及其组件选择"

The whole settings at once or maybe even as single backup/restore processes like e.g. MozBackup with its "Components selection"

或 Eclipse 及其导出首选项"对话框

or eclipse with its "Export Preferences" dialog

推荐答案

没有简单的方法来备份/导出配置的选定部分,因为 Jenkins 配置数据分散

There is no simple way to backup/export selected parts of the configuration, since Jenkins configuration data is scattered among

  • 几个文件(全局config.xml,很多插件特定的文件)
  • 几个子目录(凭据、节点)和
  • 某些文件已加密(凭据),因此您还必须备份加密密钥
  • several files (global config.xml, lots of plugin-specific files)
  • several sub-directories (credentials, nodes) and
  • some of the files are encrypted (credentials), so you must also backup the encryption keys

最干净的解决方案是备份整个 $JENKINS_HOME,并排除那些你做的部分不想成为备份的一部分(例如,排除jobs/*/builds).这样,您最终也会得到一个合理的备份大小.

The cleanest solution will be to back-up the entire $JENKINS_HOME, and to exclude those parts that you do not want to be part of the backup (e.g., exclude jobs/*/builds). With that you'll end up with a resonable backup size also.

这种备份必须在文件系统级别完成,因为没有 API 可以访问所有这些文件/数据.

Such a backup must be done on filesystem level, as there's no API to access all those files/data.

不要依赖 thinBackup,因为你依赖插件维护者不会错过任何重要的东西.例如,从 1.7.4 版本开始,thinBackup 不备份 Jenkins 的密钥,因此无法从头恢复凭据.

Do not rely on thinBackup, as you depend on the plugin maintainers to not miss anything important. E.g., as of version 1.7.4, thinBackup does not backup Jenkins' secret keys, so it's impossible to restore credentials from scratch.

这篇关于如何导出/导入 Jenkins 配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆