I want to allow running following pipeline in parallel, but I have to limit maximum number of parallel runs due to limited resources.
pipeline {
agent { label "$JENKINS_AGENT" }
parameters { .. }
options { .. }
stages {
stage('Checkout') { .. }
stage('Config') { .. }
stage('Deploy') { .. }
stage('Test') { .. }
}
post {
failure { .. }
success { .. }
always {
cleanup()
}
}
}
For example if I am limited to 3 deployments, how could I achieve this?
Edit: I have added currently the following to my jenkinsfile. Seems to work, but I'm not sure if that's the correct way to do this. (using Throttle Concurrent Builds Plugin)
properties([
[
$class: 'ThrottleJobProperty',
categories: ['parallel_pipeline'],
limitOneJobWithMatchingParams: false,
maxConcurrentPerNode: 3,
maxConcurrentTotal: 3,
paramsToUseForLimit: '',
throttleEnabled: true,
throttleOption: 'project'
],
])