我可以在项目仓库中存储Jenkins配置(如Travis CI)吗? [英] Can I store Jenkins configuration in the project repo (like Travis CI)?

查看:204
本文介绍了我可以在项目仓库中存储Jenkins配置(如Travis CI)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在源代码旁边维护SCM中的Jenkins作业配置?

How do you maintain the Jenkins job configuration in SCM along side the source code?

随着源代码的发展,作业配置也在发展。这将是理想的能够保持作业配置在SCM,以下的好处:

As source code evolves, so does the job configuration. It would be ideal to be able to keep the job configuration in SCM, for the following benefits:


  • 很容易看到谁的历史

  • 无需滚动即可重建旧的分支/标签。

  • 通过UI查找相应的部分并进行更改

我看到有一个 Jenkins Job Builder 插件。我更喜欢沿 Travis CI 的解决方案,其中作业配置在YAML文件中维护(.travis.yml)。任何好的建议?

I see there is a Jenkins Job Builder plugin. I prefer a solution along the lines of Travis CI, where the job configuration is maintained in a YAML file (.travis.yml). Any good suggestions?

注意:我们的大多数项目都使用Java& Maven。

Note: Most of our projects are using Java & Maven.

推荐答案

更新2016年:Jenkins现在提供 Jenkinsfile 提供了这个。这是由核心Jenkins开发人员支持,并积极开发。

Update 2016: Jenkins now provides a Jenkinsfile which provides exactly this. This is supported by the core Jenkins developers and actively developed.

好处:

创建一个检入源代码控制的Jenkins文件,提供了一些直接的好处:

Creating a Jenkinsfile, which is checked into source control, provides a number of immediate benefits:


  • /

  • 管道的审核追踪

  • 管道的单一真相来源,可由多位成员查看和编辑






href =https://github.com/manahl/recipebuilder =nofollow noreferrer>这样做的插件就是这样!


I've written a plugin that does this!

我的插件,你有一些(有限的)选项与现有的Jenkins插件:

Other than my plugin, you have some (limited) options with existing Jenkins plugins:

如果你配置Jenkins简单运行:

If you configure your Jenkins to simply run:

$ bash run_tests.sh

然后,您可以在您的SCM仓库中检入 run_tests.sh 文件,您如何运行测试的更改。

You can then check in a run_tests.sh file into your SCM repo and you're now tracking changes for how you run tests. However, this won't track configuration of any plugins.

同样,如果您使用的是Maven,则 Maven Project Plugin 只是为你的仓库运行一个指定的目标。

Similarly, if you're using Maven, the Maven Project Plugin simply runs a specified goal for your repo.

Literate Plugin 确实允许Jenkins在您的

The Literate Plugin does allow Jenkins to run the commands in your README.md, but it hasn't yet been released.

您可以请使用 SCM同步配置插件编写配置更改到SCM,所以你至少有一个持久的记录。这是全局的,在您的Jenkins实例的所有项目。

You can use the SCM Sync configuration plugin to write configuration changes to SCM, so you at least have a persistent record. This is global, across all projects on your Jenkins instance.

还有作业配置历史插件,它在文件系统上存储配置历史。

There's also the job config history plugin, which stores config history on the filesystem.

Jenkins工作构建器你提到的项目允许你检查配置更改到SCM,并将它们应用于你的Jenkins实例。

The Jenkins job builder project you mentioned lets you check config changes into SCM and have them applied to your Jenkins instance. Again, this is across all projects on your Jenkins instance.

请使用groovy脚本的repo脚本,使用 Job DSL插件

You can use the Job DSL Plugin with a repo of groovy scripts. Jenkins then polls that repo, executes the groovy scripts, which create job configurations.

问题996 (现已关闭)讨论了此问题,并且已在邮件列表中进行了讨论:'保持轨迹的Hudson配置更改,以及'save hudson config in svn'

Issue 996 (now closed) discusses this, and it has also been discussed on the mailing list: 'Keeping track of Hudson's configuration changes', and 'save hudson config in svn'.

这篇关于我可以在项目仓库中存储Jenkins配置(如Travis CI)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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