Skip to content
Snippets Groups Projects
Verified Commit 7956c19e authored by Varac's avatar Varac
Browse files

Remove current pipeline droplet on master

I relalized that we let MR pipeline droplets running in order to be able to
investigate, and remove them after merging to master.
*But* for master deploys we don't terminate the droplet so we keep bumping
into our budget limit often.
parent 0d9b1dda
No related branches found
No related tags found
No related merge requests found
......@@ -175,9 +175,32 @@ behave-grafana:
- test/**/*
- openappstack/**/*
# Remove droplet after merge
terminate_droplet_after_merge:
terminate_current_pipeline_droplet:
variables:
HOSTNAME: "ci-${CI_PIPELINE_ID}"
stage: cleanup
before_script:
- echo "Terminate the current pipeline droplet on success but only for \
the master branch, since we wanted to have MR droplets running even for \
successful deploys to be able to investgate."
script:
- python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${HOSTNAME}\$\")"
only:
changes:
- .gitlab-ci.yml
- ansible/**/*
- helmfiles/**/*
- test/**/*
- openappstack/**/*
refs:
- master
terminate_mr_droplet_after_merge:
stage: cleanup
before_script:
- echo "We leave MR droplets running even when the pipeline is successful \
to be able to investigate a MR. We need to terminate them when the MR \
is merged into master."
script: |
if [ "$(git show -s --pretty=%p HEAD | wc -w)" -gt 1 ]
then
......@@ -196,7 +219,7 @@ terminate_droplet_after_merge:
terminate_old_droplets:
stage: cleanup
script:
# Remove droplet older than 2 days
- echo "Terminate stale, old droplets after 2 days."
- python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^ci-\", 2)"
only:
changes:
......
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