Skip to content
Snippets Groups Projects
Commit edb316f4 authored by Ana Aviles's avatar Ana Aviles
Browse files

Merge branch '301-don-t-terminate-droplet-before-mr-is-merged' into 'master'

Resolve "Don't terminate droplet before MR is merged"

Closes #301

See merge request openappstack/openappstack!82
parents 9695e992 4b292b1d
No related branches found
No related tags found
No related merge requests found
......@@ -171,11 +171,25 @@ behave-grafana:
- test/**/*
- openappstack/**/*
terminate:
# Remove droplet after merge
terminate_droplet_after_merge:
stage: cleanup
script: |
if [ "$(git cat-file -p HEAD | grep -c '^parent')" -gt 1 ]
then
pipeline=$(git cat-file -p 893aed0e1f1ce02a77b8f2a66ad03c24f09915d9 | grep 'Merge branch' | tr -dc '0-9')
echo "Current HEAD is a merge commit, removing droplet from related merge request pipeline #${pipeline}."
python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^ci-${pipeline}\.\")"
else
echo "Current HEAD is NOT a merge commit, nothing to do."
fi
only:
refs:
- master
terminate_old_droplets:
stage: cleanup
script:
# Remove droplet after successful tests
- echo "$CI_COMMIT_MESSAGE" | grep '!ci_dont_terminate' && echo 'Termination of droplet disabled in commit message.' || python3 -m openappstack $HOSTNAME --terminate
# Remove droplet older than 2 days
- python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^ci-\", 2)"
only:
......@@ -186,7 +200,8 @@ terminate:
- test/**/*
- openappstack/**/*
# This trivial job works around a Gitlab bug: if no job runs at all due to
# We need one job that run every time (without any `only:` limitation).
# This works around a Gitlab bug: if no job runs at all due to
# `only`, Gitlab gets confused and doesn't allow you to merge the MR:
# https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html#limitations
gitlab-merge-workaround:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment