Skip to content
Snippets Groups Projects

Deployment Approvals API

Merged Alishan Ladhani requested to merge ali/deployment-approvals-api into master

What does this MR do and why?

Introduce an API endpoint to approve/reject a blocked deployment. Part of the Deployment Approvals MVC.

This API is indirectly behind the deployment_approvals feature flag. Although the flag is not checked here, we only block deployments if this feature is enabled. See https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/services/ee/ci/process_build_service.rb#L14.

Related to #343864 (closed)

How to set up and validate locally

  1. Enable the deployment_approvals feature flag.
Feature.enable(:deployment_approvals)
  1. Set up a project to deploy to an environment. Example job from .gitlab-ci.yml:
production:
  stage: deploy
  script:
    - echo done
  environment:
    name: production
  1. Protect the environment being deployed to. See https://docs.gitlab.com/ee/ci/environments/protected_environments.html#protecting-environments.

  2. Add some required approvals to the protected environment that was just created:

ProtectedEnvironment.last.update(required_approval_count: 1)
  1. Start a pipeline. The production job should be in a blocked state.

  2. Use the Deployment Approvals API to approve the deployment as a different user that has permission to deploy. See the documentation changes in this MR for details on endpoint and parameters.

  3. Verify that the production job has started.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Alishan Ladhani

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Shinya Maeda
  • Shinya Maeda approved this merge request

    approved this merge request

  • Shinya Maeda requested review from @rdickenson and removed review request for @shinya.maeda

    requested review from @rdickenson and removed review request for @shinya.maeda

  • added 1 commit

    • 1badc95c - Add Deployment Approvals API endpoint

    Compare with previous version

  • Russell Dickenson approved this merge request

    approved this merge request

  • requested review from @shinya.maeda

  • Shinya Maeda resolved all threads

    resolved all threads

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading