简体   繁体   English

Multijob DSL - 如何在 Job DSL 插件中使用特定节点/云/代理“标记”每个 phaseJob?

[英]Multijob DSL - How to “label” each phaseJob with specific node/cloud/agent in Job DSL plugin?

I'm trying to label each phaseJob in multiJob DSL plugin with specific node (in my case it's docker-cloud created with Docker Plugin).我正在尝试label具有特定节点的multiJob DSL 插件中的每个phaseJob (在我的情况下,它是使用 Docker 插件创建的 docker-cloud)。

Instead of labeling each phaseJob with specific node (docker-cloud) it labels every job with latest mentioned docker-cloud/node label.它不是用特定节点 ( docker -cloud) 标记每个阶段作业,而是用最新提到的 docker-cloud/node label 标记每个作业。

I've tried the following example DSL configuration:我尝试了以下示例 DSL 配置:

multiJob('example-multiple-job') {
    steps {
        phase('First') {
            phaseJob('JobA'){
                label('docker-a')
                shell('echo Hello World JobA!') 
                shell('sleep 1m')
            }
            phaseJob('JobB'){
                label('docker-b')
                shell('echo Hello World JobB!')
                shell('sleep 1m')
            }
        }
    }
}

So, it labels whole multiJob with docker-b label (as it is the latest one)因此,它使用 docker -b label 标记整个 multiJob(因为它是最新的)

In addition to that, I've given a try to the following syntax:除此之外,我还尝试了以下语法:

multiJob('example-multiple-job') {
    steps {
        phase('First') {
            job('JobA'){
                label('main-docker-a')
                shell('echo Hello World JobA!') //
                shell('sleep 1m')
            }
            job('JobB'){
                label('main-docker-b')
                shell('echo Hello World JobB!')
                shell('sleep 1m')
            }
        }
    }
}

It creates jobs with expected label, but they are not included in Multiple job project.它使用预期的 label 创建作业,但它们不包含在多作业项目中。

My expectentions are:我的期望是:

Each following phaseJob is runnign on it's own docker-cloud node and automatically included in Multiple job project automatically as it done without labeling.每个后续阶段作业都在其自己的docker -cloud 节点上运行,并自动包含在多个作业项目中,因为它无需标记即可完成。

After some time reading Job DSL docs I came with solution.在阅读了 Job DSL 文档一段时间后,我找到了解决方案。 Actually, just had to read it more attentive:)实际上,只需要仔细阅读即可:)

Here is working example of how several jobs with it's own labeled node/docker-cloud could be executed in parallel with, in docker containers这是一个工作示例,说明如何在 docker 容器中并行执行多个具有自己标记的节点/docker-cloud 的作业

job('JobA') {
    label('docker-a')
    steps {
        shell('echo Hello World Job-A!')
        shell('sleep 1m')
    }
}

job('JobB') {
    label('docker-b')
    steps {
        shell('echo Hello World Job-B!')
        shell('sleep 1m')
    }
}

multiJob('example-multiple-job') {
    steps {
        phase('First') {
            phaseJob('JobA')
            phaseJob('JobB')
        }
    }
}

As I unserstood, jobs and everythign else is created separatly, but multipleJob() directive just helps to manage them all with additional behavior and features.正如我所理解的那样,工作和其他一切都是分开创建的,但是multipleJob()指令只是通过附加的行为和特性来帮助管理它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用管道脚本和 docker-compose.yaml 参数化 jenkins DSL 作业 - How to parameterize jenkins DSL job with pipeline script & docker-compose.yaml Why ist Jenkins job-dsl plugin failing with ERROR: java.io.IOException: Failed to persist config.xml - Why ist Jenkins job-dsl plugin failing with ERROR: java.io.IOException: Failed to persist config.xml 如何使用 Gradle Kotlin DSL Dockerize 一个 Spring Boot 应用程序 - How to Dockerize a Spring Boot application with Gradle Kotlin DSL 如何在 kubernetes 的每个节点而不是 daemonset 中运行作业 - how to run a job in each node of kubernetes instead of daemonset 带有 docker-workflow-plugin.inside 的 Jenkins 管道 DSL 不允许通过 withEnv 设置/修改 PATH - Jenkins pipeline DSL with docker-workflow-plugin .inside doesn't allow setting/modification of PATH via withEnv Jenkins docker 插件问题 >> label 'agent' 的所有节点都下线 - Jenkins docker plugin issue >> All nodes of label ‘agent’ are offline 在特定代理 Jenkins 中的 docker 容器内运行作业 - Run job inside docker container in specific agent Jenkins 如何在詹金斯的从节点中选择 docker 代理 - how docker agent is selected in slave node in jenkins 如何在 Jenkins 从节点上运行 Dockerfile 代理? - How to run Dockerfile agent on a Jenkins Slave Node? 如何将詹金斯管道作业链接到docker slaves容器上的标签 - How to link jenkins pipeline job to label on docker slaves containers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM