Jenkins通过DSL启动工作,不等待工作完成

时间:2017-08-23 20:01:47

标签: jenkins groovy dsl

我试图通过Jenkins DSL启动项目,但不需要等待它完成。基本上我希望它能够开始一项孤儿工作。

node("slave-node")
{
    // Launch pipeline job
    stage("LaunchPipelineJob")
    {
        // this step runs for x mins and does a buch of work
        echo "Starting pipelinejob"
        def pipelinejob  = build job: 'pipelineStep'
        //echo "Pipeline job status: ${pipelinejob.result}"
    }

    // Launch the orphan
    stage("LaunchOrphanJob")
    {
        // need to kick off this job, but dont care to wait for it to finish
        echo "Starting orphanPipelinejob"
        def orphanPipelinejob  = build job: 'orphanStep'
    }
}

我查看了dsl,但无法找到有关如何启动孤儿的任何文档。 谢谢

2 个答案:

答案 0 :(得分:2)

stage{
    build job: 'pipelineStep', parameters: [string(name: 'xxx', value: xxx), string(name: 'yyy', value: yyy)],wait:false
} 
stage{
    build job: 'orphanStep', parameters: [string(name: 'xxx', value: xxx), string(name: 'yyy', value: yyy)],wait:false
}

仅供参考,当您提供wait = false时,runwrapper不会返回任何对象,因此您将无法获取与子作业(pipelineSteporphanStep )。

RunWrapper.html

答案 1 :(得分:0)

这应该这样做。

build job: 'pipelineStep', propagate: false, wait: false