JobDSL-如果Jenkins中不存在新工作,则创建一个新工作 [英] JobDSL - Create a new job if it doesn't exist in Jenkins already

查看:106
本文介绍了JobDSL-如果Jenkins中不存在新工作,则创建一个新工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了这个Groovy JobDSLs脚本来生成新的Jenkins作业.

I created this Groovy JobDSLs script to generate a new Jenkins jobs.

List screen = [["AAA", "Description" ],["AAA", "Description" ]]
for (item in screen) {
    job(item[0]) {
        description(item[1])
        steps {
            shell('command ...')
        }
    }​
}​

如果Jenkins中已经存在作业,是否有办法告诉JobDSL插件不在列表中创建作业?我不想保留用于生成新作业的单独文件.一个文件用于新作业,一个文件用于所有现有作业.

Is there a way how to tell JobDSL plugin to not create a job in the List, if it already exists in Jenkins? I don't want to keep to separate files for generating new jobs. One file for new jobs and one file for all existing jobs.

推荐答案

如果作业定义未更改,则作业DSL不会更新作业.

If a job definition does not change, Job DSL does not update a job.

如果作业定义更改,并且您想忽略这些更改,请在Process Job DSLs构建步骤中选择Action for existing jobs and views: Ignore changes选项.

If a job definition changes and you want to ignore these changes, select the Action for existing jobs and views: Ignore changes option in the Process Job DSLs build step.

如果您是在Groovy管道中以jobDsl编程地执行此操作,则它可能看起来像这样:

If you are doing this programatically with jobDsl in groovy pipeline, it may look like this:

jobDsl targets: 'jobs/**/seed.groovy', ignoreExisting: true

这篇关于JobDSL-如果Jenkins中不存在新工作,则创建一个新工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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