Your pipeline most likely looks like this:
node {
stage('build') {
// sh "make"
}
// ...
stage('trigger-project-c') {
def job = build job: 'project-c', parameters: [[$class: 'StringParameterValue', name: 'MY_PARAM', value: 'somevalue']]
}
}
By wrapping everything inside the node
closure, the downstream job project-c
is triggered inline, without the upstream job being paused / releasing an executor.
Therefore, things that do essentially nothing for a long time should not be wrapped within a node
step, in order to not block an executor. A very similar case is when using the input
step to wait for user feedback.
Instead, your pipeline should look e.g. as follows, which is - so to say - the best practice (as you don't block your executor):
stage('build') {
node {
// sh "make"
}
}
// or
node {
stage('build') {
// sh "make"
}
stage('unit') {
// sh "make"
}
} // node
// note: the following code is _not_ wrapped inside a `node` step
stage('trigger-project-c') {
def job = build job: 'project-c', parameters: [[$class: 'StringParameterValue', name: 'MY_PARAM', value: 'somevalue']]
}
There is no need to wrap the build
step within a node
, i.e., block an executor for it. For other steps (like sh
), pipeline execution would trigger an error and remind you that it cannot be run outside of a node
allocation.