diff options
author | John Cai <jcai@gitlab.com> | 2023-07-18 18:09:41 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2023-07-19 22:21:12 +0300 |
commit | 214f41afdaa2f63ba9b3f9a8224282f080f89b0f (patch) | |
tree | 8d09a3e77e166d90b71412331f0fe88846047e03 /.gitlab-ci.yml | |
parent | 20cc8073ae695bd3fcc53f35e4460941caa637d9 (diff) |
.gitlab-ci.yml: Use an environment to automatically clean up branches
Diffstat (limited to '.gitlab-ci.yml')
-rw-r--r-- | .gitlab-ci.yml | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 64e13fcb0..76fc28709 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -528,6 +528,9 @@ start-rails-specs: --data "content=$CI_MERGE_REQUEST_SOURCE_BRANCH_SHA" \ --data "commit_message=Updating GITALY_SERVER_VERSION to $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA" \ https://gitlab.com/api/v4/projects/278964/repository/files/GITALY_SERVER_VERSION + environment: + name: merge-requests/$CI_MERGE_REQUEST_IID + on_stop: rails-specs-cleanup rules: - when: manual allow_failure: true @@ -551,6 +554,20 @@ rails-specs-cleanup: - | curl --request DELETE --header "PRIVATE-TOKEN: $GITLAB_PROJECT_TOKEN" \ "https://gitlab.com/api/v4/projects/278964/repository/branches/$RAILS_BRANCH_FOR_MERGE_REQUEST" + environment: + name: merge-requests/$CI_MERGE_REQUEST_IID + action: stop + +cleanup-rails-spec-test-env: + needs: ["rails-specs-cleanup"] + stage: qa + before_script: + - apt update + - apt install -y jq + script: + - | + ENV_ID=$(curl -s --request GET --header "PRIVATE-TOKEN: $GITALY_PROJECT_TOKEN" "https://gitlab.com/api/v4/projects/2009901/environments?name=merge-requests%2F$CI_MERGE_REQUEST_IID" | jq '.[0].id') + curl -s --request DELETE --header "PRIVATE-TOKEN: $GITALY_PROJECT_TOKEN" "https://gitlab.com/api/v4/projects/2009901/environments/$ENV_ID" build-package-and-qa: needs: [] |