如何为每个(新)Jenkins 作业创建默认配置?

How to create a default configuration for each (new) Jenkins job?

在我长期使用 Jenkins 的过程中,我想出了一组默认值,用于每个新工作,例如:

等等

..但现在我将它们设置为 manually/copy 现有工作作为新工作的模板,但这显然不是最佳选择。


我一直在寻找 plugin/setting 来配置新 jobs/global 作业设置的默认设置,这些设置会覆盖每个作业设置,但我还没有找到任何解决方案。

你知道怎么做吗?

更新

我看过 Configuration Slicing Plugin 但我不清楚这是否有帮助..

更新 2

我刚刚想起了 Jenkins Job DSL / Plugin,我很快就会研究它的功能,但我仍然对入门级别较低的更简单的解决方案感兴趣。

我这样做的方法是使用仅用作模板的默认选项创建作业。然后在创建新作业时,我 select 选项 "Copy from" 并写下模板作业的名称。

一个更好的解决方案是使用继承之类的东西 - 有一个其他作业继承的父作业,所以如果你想为所有作业添加一个选项,你只需要将它添加到父作业。 Inheritance plugin 似乎可以做到这一点,但不幸的是,它会干扰其他插件并在尝试配置时崩溃。

您可以尝试 Job DSL 通过构建您的工作(使用另一份工作)来执行 Dev Ops 'configuration as code'

The Jenkins "Job DSL / Plugin" is made up of two parts: The Domain
Specific Language (DSL) itself that allows users to describe jobs 
using a Groovy-based language, and a Jenkins plugin which manages 
the scripts and the updating of the Jenkins jobs which are created 
and maintained as a result.

或者,新的方法是定义一个 pipeline (Jenkins 2.0) 这是你的 repo

根目录中的 Jenkinsfile
Jenkins Pipeline is a suite of plugins which supports implementing 
and integrating continuous delivery pipelines into Jenkins. Pipeline
provides an extensible set of tools for modelling simple-to-complex
delivery pipelines "as code" via the Pipeline DSL.