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
Job DSL was one of the first popular plugins for Jenkins which allows managing configuration as code and many other plugins dealing with this aspect have been created since then, most notably the Jenkins Pipeline and Configuration as Code plugins.
Create a pipeline . In the Configuration stage of your new pipeline, add a trigger . Select Jenkins from the Type menu, which brings up the following screen: Select a Jenkins master from the Master drop-down menu, then select a job from the Job drop-down.
For the rest of you, a quick refresher: job-dsl is a way of creating Jenkins jobs with code instead of the GUI. Here’s a very simple example: When processed via a Jenkins seed job, this code will turn into the familiar Jenkins jobs you know and love. What are Pipelines?
Note: If searching for Job DSL returned no results, it either means the Job DSL plugin is already installed, or that your Jenkin server’s plugin list is not updated. You can check if the Job DSL plugin is already installed by navigating to your_jenkins_url /pluginManager/installed and searching for Job DSL.
If any of them are not installed, go to your_jenkins_url /pluginManager/available and search for and select the plugins, then click Install without restart. Now that the required plugins are installed, let’s shift our focus to modifying your Job DSL script to include an additional pipeline job.
To create the seed job, go to your_jenkins_url, log in (if necessary), click the New Item link on the left of the dashboard. On the screen that follows, type in seed, select Freestyle project, and click OK. In the screen that follows, scroll down to the Build section and click on the Add build step dropdown. Next select Process Job DSLs.
This should do it.
build job: 'pipelineStep', propagate: false, wait: false
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With