简体   繁体   English

Jenkins 配置即代码 - 从另一个实例迁移配置

[英]Jenkins Configuration as Code - migrate configuration from another instance

I'm moving a Jenkins from 'traditional' to JCasC .我正在将 Jenkins 从“传统”移动到JCasC We have a quite complex setup already, and I am wondering if there is a way to migrate somehow the current configuration without a need of going through settings and code it in.yaml?我们已经有一个相当复杂的设置,我想知道是否有一种方法可以以某种方式迁移当前配置,而无需通过设置并将其编码在.yaml 中?

btw.顺便提一句。 I'm not sure about installing JCasC plugin on prod to see the configuration... Am I wrong?我不确定在 prod 上安装 JCasC 插件以查看配置...我错了吗?

Thanks!谢谢!

Make sure to have read the Getting Started and other docs.确保已阅读入门和其他文档。

Create new instance (you can do this onto your desktop/laptop) and copy over all the configuration, config.xml,*.xml, secrets and keys, but NO jobs into the new instance.创建新实例(您可以在桌面/笔记本电脑上执行此操作)并将所有配置、config.xml、*.xml、机密和密钥复制到新实例中,但没有作业。 See what to backup .看看要备份什么

Add an entry to start in quiet mode by adding Jenkins.instance.doQuietDown()通过添加Jenkins.instance.doQuietDown()添加一个条目以在安静模式下启动

You might want/need to change the url and port config too.depending on host.您可能想要/需要更改 url 和端口配置。取决于主机。 Mind you, you can do this all onto your desktop/laptop请注意,您可以在台式机/笔记本电脑上完成所有操作

Copy the plugins as well.也复制插件。 Add the config as code plugin.将配置添加为代码插件。

Startup the new instance, export the CasC config and review.启动新实例,导出 CasC 配置并查看。 The export is a starting point so fill in any missing gaps, etc. For example, since you did not copy jobs over, folders and views will not be created.导出是一个起点,因此请填写任何缺失的空白等。例如,由于您没有复制作业,因此不会创建文件夹和视图。 Some plugin configs are.also not yet implemented.一些插件配置还没有实现。

Stop Jenkins, delete all the config (except the secret key).停止 Jenkins,删除所有配置(除了密钥)。 Put the JCasC config in place and start up.放置 JCasC 配置并启动。 Compare the new configs to what you backed up/copied over.将新配置与您备份/复制的内容进行比较。 Repeat until they match.重复直到它们匹配。 Now you should have a config that matches Prod.现在您应该有一个与 Prod 匹配的配置。

Now you can install JCasc in Prod.现在您可以在 Prod 中安装 JCasc。 The plugin does nothing until configured.该插件在配置之前什么都不做。 But do a similar backup/compare of Prod config, before and after the config, just in case something changed in the intervening period但是在配置之前和之后对 Prod 配置进行类似的备份/比较,以防在此期间发生某些变化

Of course, now you need to mke sure any changes are now only done via JCasC and not the UI, or you are out of sync again.当然,现在您需要确保任何更改现在仅通过 JCasC 而不是 UI 完成,否则您将再次不同步。 See blog and JEP .请参阅博客JEP

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

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