Commit 18cbc266 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '218167-stop-review-for-ecs' into 'master'

Add a stop review job for ECS

See merge request gitlab-org/gitlab!44717
parents fef0b92f 5d28cb54
---
title: Add a stop review job for ECS
merge_request: 44717
author:
type: added
...@@ -8,8 +8,11 @@ ...@@ -8,8 +8,11 @@
# #
# More about including CI templates: https://docs.gitlab.com/ee/ci/yaml/#includetemplate # More about including CI templates: https://docs.gitlab.com/ee/ci/yaml/#includetemplate
.deploy_to_ecs: .ecs_image:
image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-ecs:latest' image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-ecs:latest'
.deploy_to_ecs:
extends: .ecs_image
dependencies: [] dependencies: []
script: script:
- ecs update-task-definition - ecs update-task-definition
...@@ -17,8 +20,6 @@ ...@@ -17,8 +20,6 @@
.review_ecs_base: .review_ecs_base:
stage: review stage: review
extends: .deploy_to_ecs extends: .deploy_to_ecs
environment:
name: review/$CI_COMMIT_REF_NAME
.production_ecs_base: .production_ecs_base:
stage: production stage: production
...@@ -26,8 +27,18 @@ ...@@ -26,8 +27,18 @@
environment: environment:
name: production name: production
.stop_review_ecs_base:
extends: .ecs_image
stage: cleanup
allow_failure: true
script:
- ecs stop-task
review_ecs: review_ecs:
extends: .review_ecs_base extends: .review_ecs_base
environment:
name: review/$CI_COMMIT_REF_NAME
on_stop: stop_review_ecs
rules: rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"' - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
when: never when: never
...@@ -39,8 +50,46 @@ review_ecs: ...@@ -39,8 +50,46 @@ review_ecs:
when: never when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
stop_review_ecs:
extends: .stop_review_ecs_base
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
when: never
- if: '$CI_KUBERNETES_ACTIVE'
when: never
- if: '$REVIEW_DISABLED'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
when: manual
review_fargate: review_fargate:
extends: .review_ecs_base extends: .review_ecs_base
environment:
name: review/$CI_COMMIT_REF_NAME
on_stop: stop_review_fargate
script:
- ecs update-task-definition
rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"'
when: never
- if: '$CI_KUBERNETES_ACTIVE'
when: never
- if: '$REVIEW_DISABLED'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
stop_review_fargate:
extends: .stop_review_ecs_base
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
rules: rules:
- if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"' - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "FARGATE"'
when: never when: never
...@@ -51,6 +100,7 @@ review_fargate: ...@@ -51,6 +100,7 @@ review_fargate:
- if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH == "master"'
when: never when: never
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
when: manual
production_ecs: production_ecs:
extends: .production_ecs_base extends: .production_ecs_base
......
...@@ -94,14 +94,14 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do ...@@ -94,14 +94,14 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
end end
it 'creates an ECS deployment job for review only' do it 'creates an ECS deployment job for review only' do
expect(review_prod_build_names).to contain_exactly('review_ecs') expect(review_prod_build_names).to contain_exactly('review_ecs', 'stop_review_ecs')
end end
context 'with FARGATE as a launch type' do context 'with FARGATE as a launch type' do
let(:platform_value) { 'FARGATE' } let(:platform_value) { 'FARGATE' }
it 'creates an FARGATE deployment job for review only' do it 'creates an FARGATE deployment job for review only' do
expect(review_prod_build_names).to contain_exactly('review_fargate') expect(review_prod_build_names).to contain_exactly('review_fargate', 'stop_review_fargate')
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment