Run stages in parallel
You can run stages in parallel when you want to perform parallel operations. For example:
- In CI stages, parallel execution of builds and tests can speed up the integration process, reduce test time, and provide faster feedback to developers.
- In CD stages, parallel execution of deployments can help reduce deployment times and increase the efficiency of the process.
- in Infrastructure as Code (IaC), parallel execution of IaC scripts can speed up the creation of resources and improve the scalability of infrastructure.
To run stages in parallel, add stages to your pipeline, and then arrange the stages to run in parallel.
- Visual editor
- YAML editor
In the Visual editor, you can drag-and-drop stages to arrange them in parallel.
Once grouped in parallel, you can hover over the parallel group and select the stage you want to inspect or edit.
In the YAML editor, indent the stages under a parallel
flag.
stages:
- parallel: ## Stages indented under this flag will run in parallel.
- stage:
...
- stage:
...
- stage: ## This stage is not in the parallel group.
In Continuous Delivery, a resource constraint step is added to every stage automatically to make sure that you are not using two infrastructures simultaneously. Hence, one parallel stage executes first. Once the execution of the first stage finishes, the other stage(s) will start.
You can deploy multiple services to multiple environments in a single deployment stage; however, running multi-service stages in parallel deploys each service to each environment in parallel. This can become complicated. For such use cases, Harness recommends using separate stages.