I am using below code snippet for deploying code to multiple environments parallelly . For example I have two environments acpt, acpt2. The function Deploy executes from shared library which loaded at first to below script . The problem is when it tries to deploy first environment “acpt” as its parallel stage it moves to “acpt2” environment and it never deploys to acpt environment. How to get around this issue ? Any thoughts?
stage('Deployment Distribution') {
steps {
script {
for (int i = 0; i < environments.size(); i++) {
env.environ = environments[i]
jobs["${env.environ}"] = {
node("XXXXX") {
stage("Deploy ${env.environ}") {
Deploy("${env.environ}") /// This function is written in shared library
sleep 10
}
}
}
}
parallel jobs
}
}
}
I finally went with sequential deployment which is time consuming but no other option