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

Gre*_*cki 5 default jenkins

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

  • 使用Workspace Cleanup Plugin在每次构建之前清理工作区,
  • 将时间戳添加到控制台输出,
  • 使用相同的SCM查看器

等等

..但是现在我手动设置/复制现有作业作为新模板的模板,但这显然不是最佳的.


我找了一个插件/设置,可以让我配置新作业/全局作业设置的默认设置,它将覆盖每个作业设置,但我还没有找到任何解决方案.

你知道怎么做吗?

更新

我看过配置切片插件,但我不清楚这是否会有所帮助..

更新2

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

Kee*_*yOn 2

您可以尝试使用Job DSL,它通过构建您的作业(使用另一个作业)来执行 Dev Ops“配置即代码”

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.
Run Code Online (Sandbox Code Playgroud)

或者,新的方法是定义一个管道(Jenkins 2.0),它位于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. 
Run Code Online (Sandbox Code Playgroud)