How to pause pipelines for manual approval
The approval step allows you to pause a pipeline and wait for human intervention before going on.
Some example scenarios for using the approval step:
- Pause before deploying to production
- Pause before destroying an environment
- Pause for some manual smoke tests or metric collection
||The free-text display name of the step.||Optional|
||A basic, free-text description of the step.||Optional|
||Defines an automatic approval/rejection if a specified amount of time has passed. The
||Parent group of this step. See using stages for more information.||Optional|
||Define a set of conditions that need to be satisfied in order to execute this step. You can find more information in the Conditional Execution of Steps article.||Optional|
Pausing the pipeline
Once the pipeline reaches an approval step it will stop. At this point it does not consume any resources. In the Codefresh UI you will see the Approve/Reject buttons.
Once you click any of them the pipeline will continue. Further steps in the pipeline can be enabled/disabled according to the approval result.
By default, a pipeline that contains an approval step will pause for ever onces it reaches that step. If you want some automatic action to happen after a specified time period you can defined it in advance with the
This pipeline will wait for approval for two hours. If somebody approves it, it will continue. If nothing happens after two hours the approval step will be automatically rejected.
By default, any Codefresh user can approve any pipeline that is paused at the approval state. If you want to restrict the approval action to a subset of people, you can use the Access Control facilities that Codefresh provides.
This is a two-step process. First you need to tag your pipeline with one or more tags (tag names are arbitrary). You can edit tags in the pipeline settings screen.
Once you have tagged your pipelines you can create one or more access rules that restrict approval to specific teams within your organization.
For more details on access control and users see also the account management page.
Getting the approval result
As also explained in step dependencies all steps in the Codefresh pipeline belong to a global object
steps (indexed by name). You can read the
result property for an approval step to see if it was approved or rejected.
Here is an example:
In this example the second step that is destroying an environment will only run if the user approves the first step. In case of rejection the second step will be skipped.
You can follow the same pattern for running steps when an approval step was rejected. Here is a full example with both cases.
Here is the pipeline state after a rejection:
You can see that only two steps were ignored. If you rerun the pipeline and approve it, the other two steps will be ignored.
If you also enable Slack integration in Codefresh you will have the choice of approving/rejecting a pipeline via a Slack channel
To enable this behavior, you need to activate it in the Slack settings page:
Also, if you run a pipeline manually that includes an approval step you should check the “Report notification of pipeline execution” checkbox as explained in Monitoring Pipelines.