'Manual approval in GitLab CI deployment pipeline
we've got a GitLab CI build / test / deployment pipeline and need to insert a manual approval between deployment to Test and promoting to Prod. I can't figure out how to do that.
Ideally we would like to have a button like in GoCD or in AWS CodePipeline. However for our current project we use GitLab EE (ver 12.3.5-ee) hosted on our servers, not using gitlab.com, but I guess the .gitlab-ci.yml
should be the same.
This is a part of my current .gitlab-ci.yml
:
stages:
# lint, build, test, ...
- deploy_test
- approval
- deploy_prod
deploy_test:
stage: deploy_test
only:
refs:
- prod
script:
...
wait_for_approval:
stage: approval
# how do I do this???
deploy_prod:
stage: deploy_prod
only:
refs:
- prod
script:
...
Any idea?
Solution 1:[1]
Use when: manual
in your stage.
To be sure the manual action is blocking (and no optionnal), add also allow_failure: false
(is set to true
by default)
More info in the documentation
Note : if you created the stage only for the approval, I could advice you to remove it and put the when: manual
in the deploy_prod
stage.
Solution 2:[2]
deally we would like to have a button like in GoCD or in AWS CodePipeline
In addition, of when:manual
, you also have GitLab 14.9 (March 2022), which comes with (still for GitLab Premium/Ultimate only):
Deployment Approval on the Environments page
We are excited to introduce the Deployment Approval capability in the GitLab interface. In GitLab 14.8, we introduced the ability to approve deployments via the API.
Now, deployment approvers can view a pending deployment and approve or reject it conveniently directly in the Environments page. This update continues our work to enable teams to create workflows for approving software to go to production or other protected environments.
With this update, we are now upgrading the feature to beta.See Documentation and Issue.
And GitLab 14.10 (April 2022) comes with:
Multiple approval rules for deployment approvals API
Previously, deployment approvals supported a simple model where the ability to execute a deployment and approve a deployment were both controlled with a single list of users.
With this update, you have more flexibility and granularity with these rules and can specify multiple levels of control using the API.
- One type of model that can now be supported is where there is separation of duties between deployment executors and approvers in your organization.
- Another supported model is where approval is needed separately from multiple levels, such as a QA tester group and a security group.
See Documentation and Issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 |