How to Deploy to Multiple Regions in Parallel in Jenkins
A parallel block deploys to each region simultaneously, so total time is the slowest region, not their sum.
Wrap one deploy branch per region in a parallel block. Each branch runs the same deploy with a different region argument, and the stage waits for all to finish.
Steps
- Define a
parallelblock inside the deploy stage. - Add one branch per region with its region argument.
- The stage completes when all regional deploys finish.
Pipeline
Jenkinsfile
pipeline {
agent any
stages {
stage('Deploy regions') {
parallel {
stage('us-east-1') { steps { sh './deploy.sh --region us-east-1' } }
stage('eu-west-1') { steps { sh './deploy.sh --region eu-west-1' } }
stage('ap-south-1'){ steps { sh './deploy.sh --region ap-south-1' } }
}
}
}
}Gotchas
- By default one failing branch fails the whole stage; add
failFast trueto stop the rest early. - Each parallel branch needs an available executor, so size the agent pool accordingly.
Related guides
How to Deploy a Helm Chart to Multiple Clusters in JenkinsDeploy one Helm chart to several Kubernetes clusters from a Jenkins Declarative Pipeline by looping over kube…
How to Deploy to AWS With an Assumed Role in JenkinsDeploy to AWS from a Jenkins Declarative Pipeline by assuming an IAM role with sts assume-role, exporting tem…