How do I use the approvals section in a pipeline as code?

Modified on Wed, 21 Jun 2023 at 02:51 PM

To use the approvals section in a GitLab pipeline as code, you can define a set of approval rules that determine who needs to approve a pipeline before it can proceed to the next stage. The approvals section allows you to specify the number of required approvals and the list of approvers.


Here's an example of how you can use the approvals section:


approvals:
  rules:
    - name: Approve pipeline
      when: manual
      allow_failure: false
      approvals:
        - username: john
        - username: jane


In the above example:


approvals is the keyword that indicates the start of the approvals section.

rules specifies the list of approval rules.

name is the name of the approval rule.

when specifies when the approval should be requested. In this case, manual indicates that the approval is required manually.

allow_failure defines whether the pipeline can proceed without the approval. Set it to false to require approval before proceeding.

approvals lists the usernames of the individuals who need to approve the pipeline. Replace john and jane with the actual usernames.

By using the approvals section, you can enforce an approval process for critical stages in your pipeline. This ensures that designated approvers review and authorize the pipeline before it progresses further.


If you have further questions or need assistance with implementing the approvals section or optimizing your pipelines, feel free to reach out to Cloud-Runner. We specialize in helping developers maximize the efficiency and performance of their CI/CD workflows. Visit cloud-runner.com to learn more about our services and how we can support your pipeline automation needs.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article