In a gitlab pipeline, I have 3 jobs from 3 stages for deploying to an environment, eg. staging
environment. In real application, the first stage is bootstrap stack, the second is application stack proposed changes and third stage is apply changes to application stack. All apply changes to staging environment. I have mocked the current pipeline with a test pipeline which is given below. I have when: manual
in the deploy stage
stage’s job and have defined needs
for second stage and the third stage. When pipeline is approved at first stage it also requires approval at other two stages.
I want only one approval should be enough to complete the deployment to staging environment.
This is how the current pipeline setup looks like:
stages:
- build
- deploy dev
- test dev feature
- deploy stage
- test stage deploy
- integration test stage
- deploy prod
- go live
build:
stage: build
script:
- echo "Build artifacts"
deploy_dev:
stage: deploy dev
environment: dev
script:
- echo "Deploying to dev" > deploy_dev.log
artifacts:
paths:
- deploy_dev.log
test_feature_dev:
stage: test dev feature
environment: dev
script:
- echo "test the developer feature" > dev_feature.log
artifacts:
paths:
- dev_feature.log
deploy_stage:
stage: deploy stage
environment: stg
script:
- echo "Deploying to staging env" > deploy_stg.log
only:
- main
artifacts:
paths:
- deploy_stg.log
when: manual
test_feature_stage:
stage: test stage deploy
environment: stg
script:
- echo "test the staging" > stage_feature.log
only:
- main
artifacts:
paths:
- stage_feature.log
needs:
- deploy_stage
integration_test_stage:
stage: integration test stage
environment: stg
script:
- echo "integratin test" > integration_test.log
only:
- main
artifacts:
paths:
- integration_test.log
needs:
- test_feature_stage
deploy_prod:
stage: deploy prod
environment: prod
script:
- echo "Deploying to production env" > deploy_prod.log
only:
- main
artifacts:
paths:
- deploy_prod.log
when: manual
go_live:
stage: go live
environment: prod
script:
- echo "Going live... stay tuned -> "
only:
- main
needs:
- deploy_prod
After manual approval at deploy stage
, the test stage deploy
and integration test stage
should run by itself without need for an approval. However, the pipeline enters the block at test stage deploy
and also at integration test stage
and requires manual approval.
Additional information, in pipeline setup, the 2 approval rules are in place: A maintainer
group which can approve the build and A maintainer + developer
group who can deploy to stage
environment.
I need only one approval should be enough which is at deploy stage
. However, have to provide approval at all thress stages. Any pointers how it can be fixed?