詹金斯DSL插件:如何在现有的jenkins视图中创建工作? [英] Jenkins DSL Plugin: How to create a job in an existing jenkins View?

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

问题描述

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

将作业添加到新创建的视图中。



如何使用DSL插件将创建的作业添加到现有视图?我无法在文档中找到任何提示。也许这太明显,我不能看到解决方案?



虽然我读过,但如果视图已经存在,那么创建视图将导致重新创建。这意味着什么对于现有的项目?



感谢您的帮助。

解决方案

您无法将作业添加到不受作业DSL管理的视图。但是,由DSL管理的视图可以包含不由DSL管理的作业。

例如,您可以执行名为 project-a的作业这是由DSL管理的手动管理和一个名为 project-b 的作业。

  job('project-b'){
}

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

无法使用Jenkins API将作业添加到从DSL脚本查看。该作业必须存在才能被添加到视图中。但是当脚本执行时,作业不会立即创建。所有DSL项目都是在脚本处理完成后创建的。



如果您不想使用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视图中创建工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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