8

Im trying to launch a project through Jenkins DSL but dont need to wait for it to complete. Basically i want it to kick off an orphan job.

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'
    }
}

i have looked over the dsl but cant find any docs on how to start an orphan. Thank you

Lukas Gravley
  • 81
  • 1
  • 4

2 Answers2

9

This should do it.

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

Onur Gokkocabas
  • 194
  • 1
  • 11
6
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
}

FYI, when you give, wait = false, The runwrapper won't return any object, so you will not be able to fetch any details related to child jobs (pipelineStep and orphanStep).

RunWrapper.html

David Buck
  • 3,752
  • 35
  • 31
  • 35