本文介绍了詹金斯DSL插件:如何在现有的jenkins视图中创建工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了以下有关作业创建的问题,并通过DSL插件添加到新创建的视图中。

创建更复杂的过滤器。


I found the following question regarding job creation and adding to a newly created view with the DSL plugin.

Adding job to newly created view.

How can i add a created job to an existing view with the DSL plugin? I couldn´t find any hint in the documentation. Maybe it is too obvious that i can´t see the solution?

Although i read, that creating a view will cause a re-creation if the view already exists. What means that for the existing projects under this view?

Thanks for your help.

解决方案

You can not add a job to a view that is not managed by the Job DSL. But the views managed by the DSL can contain jobs which are not managed by the DSL.

For example you can have a job called project-a which is managed manually and a job called project-b which is managed by the DSL. And a view managed by the DSL can contain both jobs.

job('project-b') {
}

listView('project-view') {
  jobs {
    name('project-a')
    name('project-b')
  }
}

It's not possible to use the Jenkins API to add a job to a view from a DSL script. The job has to exist before it can be added to a view. But when the scripts is executed, the job is not created immediately. All DSL items are created after the script has been processed.

If you do not want the manage the view with the DSL (but you should), you can try to use a filter-based view configuration. E.g. include all jobs with a name matching a regular expression. Or you can use the View Job Filters Plugin to create more complex filters.

这篇关于詹金斯DSL插件:如何在现有的jenkins视图中创建工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 21:45