Skip to content

Provide support for multiple approval rules

What does this MR do and why?

For multiple deployment approval rules, we want to show a more informative table, listing each rule and who has approved to complete the rule.

Changelog: added

Screenshots or screen recordings

before after
image image

How to set up and validate locally

  1. Create some environments
stages:
    - deploy
    - stop
image: alpine:latest

deploy-prod:
    stage: deploy
    script:
        - sleep 10
        - echo "deploying prod"
    environment:
        name: production
        url: postgres://example.com

deploy-staging:
    stage: deploy
    script:
        - echo "deploying staging I hope"
    environment:
        name: staging
        url: https://example.com
    when: manual

deploy-development:
    stage: deploy
    script:
        - echo "deploying development"
    environment:
        name: development
        url: https://example.com
    when: manual

deploy-review:
    stage: deploy
    script:
        - echo "Deploying review/$CI_COMMIT_REF_NAME"
    environment:
        name: review/$CI_COMMIT_REF_NAME
        auto_stop_in: 1 week
    only:
        - branches
    except:
        - main
    when: manual


stop_review_app:
  script: stop-review-app
  stage: stop
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    action: stop
  rules:
    - if: $CI_MERGE_REQUEST_ID
      when: manual
  1. Run a pipeline to generate environments
  2. Protect the deployment environment
curl -i -H Content-Type\:\ application/json -H PRIVATE-TOKEN\:\ <MY TOKEN> -XPOST http\://gck.test\:3000/api/v4/projects/<PROJECT ID>/protected_environments/ -d \{'
'\ \ \ \ \"name\"\:\ \"development\"\,'
'\ \ \ \ \"deploy_access_levels\"\:\ \[\{\"access_level\"\:\ 40\}\]\,'
'\ \ \ \ \"approval_rules\"\:\ \['
'\ \ \ \ \ \ \ \ \{\ \"group_id\"\:\ <SOME GROUP ID>\,\ \"required_approvals\"\:\ 2\,\ \"group_inheritance_type\"\:\ 1\}\,'
'\ \ \ \ \ \ \ \ \{\ \"user_id\"\:\ 1\,\ \"required_approvals\"\:\ 1\}\,'
'\ \ \ \ \ \ \ \ \{\"access_level\"\:\ 40\,\ \"required_approvals\"\:\ 1\}'
'\ \ \ \ \]'
'\}'
'
  1. run a pipeline
  2. view environments table, deployment approvals for the deployment environment.

MR acceptance checklist

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

#355708 (closed)

Edited by Andrew Fontaine

Merge request reports

Loading