Pause your pipelines and resume after manual approval

Pause your pipelines and resume after manual approval

3 min read

One of the most important differences between Continuous Deployment and Continuous Delivery is the level of human involvement in a pipeline. The typical Continuous Delivery pipeline requires a person to approve deployment to production, where Continuous Deployment pipelines are fully automated (every feature that passes tests and checks is deployed right way).

After several customer requests, Codefresh has implemented the final piece of this puzzle and allows you to pause a pipeline before moving on.

Approval to production
Approval to production

This is accomplished using the approval pipeline step which is very easy to use in pipelines just by inserting 3 extra lines:

waitForInputBeforeProduction:
   type: pending-approval
   title: Deploy to Production?

The approval step also has the capability to be queried for its result. You can easily use it for other tasks such as waiting for any “destructive actions”. Here is a pipeline that will only destroy a test environment if the approval step is actually enabled:

Approval result
Approval result

If the user rejects the step, the test environment is never destroyed. This is accomplished by using the standard step dependencies in Codefresh.

version: '1.0'
steps:
 askForPermission:
   type: pending-approval
   title: Destroy QA environment?
 destroyQaEnvNow:
   image: alpine:3.8
   title: Destroying env
   commands:
   - echo "Destroy command running"
   when:
     steps:
     - name: askForPermission
       on:
       - approved

The destruction step in this pipeline is checking the approval status before actually continuing. Otherwise, it is skipped.

A more advanced use case is to use a single approval step in order to take a binary decision within a pipeline. So instead of using it as a gateway to production, you can actually choose for the deployment target.

Here is a pipeline that deploys in production or staging depending on the approval step:

Choose environment
Choose environment

This is the Codefresh yaml:

version: '1.0'
stages:
- prepare
- yesPleaseDo
- noDont

steps:
 step_1:
   image: alpine:3.8
   title: building chart
   stage: prepare
   commands:
   - echo "prepare"
 deployToProdNow:
   type: pending-approval
   title: Should we deploy to prod
   stage: prepare
 step_2:
   image: alpine:3.8
   title: prepare environment
   stage: yesPleaseDo
   commands:
   - echo "world"
   when:
     steps:
     - name: deployToProdNow
       on:
       - approved
 step_3:
   image: alpine:3.8
   title: deploy to production
   stage: yesPleaseDo
   commands:
   - echo "world"
   when:
     steps:
     - name: deployToProdNow
       on:
       - approved
 step_4:
   image: alpine:3.8
   title: prepare environment
   stage: noDont
   commands:
   - echo "world"
   when:
     steps:
     - name: deployToProdNow
       on:
       - denied
 step_5:
   image: alpine:3.8
   title: deploy to staging
   stage: noDont
   commands:
   - echo "world"
   when:
     steps:
     - name: deployToProdNow
       on:
       - denied 

Here is the output for production deployment (the staging steps are skipped):

Pipeline approved
Pipeline approved

And here is the output for staging deployment (the production steps are skipped):

Pipeline Rejected
Pipeline Rejected

Finally, notice also that the approval step can be used from a Slack channel as well 🙂

Slack approval
Slack approval

The approval step is available to all Codefresh plans. Notice that during the approval phase no pipeline resources are consumed. See the documentation for more details.

New to Codefresh? Create Your Free Account Today!

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Build your GitOps skills and credibility today with a GitOps Certification.

Get GitOps Certified

Ready to Get Started?
  • safer deployments
  • More frequent deployments
  • resilient deployments