简体   繁体   English

在Jenkins模板引擎中实现版本控制

[英]Implementing versioning in Jenkins Templating Engine

We are planning to use JTE(Jenkins Templating Engine)for creating pipelines in our org. 我们计划使用JTE(詹金斯模板引擎)在我们的组织中创建管道。 There are going to be many pipelines that will use this template. 将有许多使用此模板的管道。 Potentially, any change in template can break some pipeline. 模板中的任何更改都可能会中断某些渠道。 To avoid this we would like to implement versioning in templates so that we can be sure that any changes in templates would not break existing pipelines. 为了避免这种情况,我们希望在模板中实现版本控制,以便我们可以确保模板中的任何更改都不会破坏现有管道。

This is for gradle projects that would be using Jenkinsfile defined in the template. 这适用于将使用模板中定义的Jenkinsfile的gradle项目。 One option we have is to use different branches but that is messy. 我们有一个选择是使用不同的分支,但这很麻烦。 Has anyone done anything like this for JTE? 有人为JTE做过这样的事情吗?

@Steven-terrana @史蒂文-特拉纳

just seeing this! 只是看到这个! I'd recommend the gitter channel or opening an issue at github.com/jenkinsci/templating-engine-plugin to get the fastest response! 我建议使用gitter频道,或在github.com/jenkinsci/templating-engine-plugin上打开问题以获得最快的响应!

I'm not sure that anyone has tried to implement that particular use case but I can think of two primary ways i'd handle it depending upon your specific requirements. 我不确定是否有人尝试实现该特定用例,但是我可以根据自己的特定需求想到两种主要的处理方式。

If you're trying to version the template and apply the new version to everyone at the same time, then I would recommend creating release branches for your governance tier repository for teams to consume and then updating which release you point to. 如果您要对模板进行版本控制并同时将新版本应用于所有人,则建议您为治理层存储库创建发行分支,以供团队使用,然后更新指向的发行版。 If you also put your pipeline libraries in this repository it would have the benefit of packaging everything into a single release so that versions of libraries and templates stay together. 如果还将管道库也放置在此存储库中,则可以将所有内容打包到一个发行版中,从而使库和模板的版本保持在一起。

If you want to have multiple versions of your templates out there and allow teams to upgrade when it's convenient for them, then i would recommend using the pipeline_templates directory capability to have named templates. 如果您想使用模板的多个版本,并允许团队在方便时进行升级,那么我建议您使用pipeline_templates目录功能来命名模板。 You could create a different file for each release (ie, named v1, v2, etc) and then allow teams to choose their template in their configuration files via pipeline_template="v1" . 您可以为每个发行版创建一个不同的文件(即,名为v1,v2等),然后允许团队通过pipeline_template =“ v1”在其配置文件中选择其模板。

I hope this helps! 我希望这有帮助!

Relevant docs: 相关文档:

Pipeline Template Selection 管道模板选择

Governance Tiers 治理层

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

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