Delete dynamic environments (aka Review Apps)
Description
We're shipping #21971 (closed) in 8.12, but it only supports creating environments dynamically for branches. We need to provide some way to clean up (delete) environments when MRs are merged and/or branches are deleted. This means deleting the environment in GitLab, as well as deleting the backing environment, wherever it is hosted.
Proposal
Specify on_close: job_name
to point to a manual action job to run when deleting a branch or when someone manually deletes an environment from the web UI.
At job-level:
review_apps:
environment:
name: review/$CI_BUILD_REF_NAME
url: review-app-${CI_BUILD_REF_NAME}.herokuapp.com
on_close: delete_app
delete_app:
script:
- heroku destroy --confirm review-app-${CI_BUILD_REF_NAME}
when: manual
[Optional] At top-level, declare all environments so that they can be declared once, but used in multiple jobs. Also, by using an array, we can have a defined order for the environments which may help with Cycle Analytics detecting "production":
environments:
- review/*:
url: review-app-${CI_BUILD_REF_NAME}.herokuapp.com
on_close: delete_app
- staging:
url: foo-staging.herokuapp.com
- production:
url: foo-prod.herokuapp.com
delete_app:
script:
heroku destroy --confirm review-app-${CI_BUILD_REF_NAME}
when: manual
Single Source of Truth
We will leave "Manual actions on pipeline graph" https://gitlab.com/gitlab-org/gitlab-ce/issues/22604#note_16369778 out of sight for now.. leave that for next release ;).
The simplest implementation for the pipeline graph is to change the play
icon with the stop
icon. We also will leave the background color intact for now:
In the future we may well be changing this to perhaps: image
MR view is staying like this: (we can now actually just use the font-awesome icon for this http://fontawesome.io/icon/stop-circle-o/ )
https://gitlab.com/gitlab-org/gitlab-ce/issues/22628 has been updated already with designs.
https://gitlab.com/gitlab-org/gitlab-ce/issues/22642 can be considered part of that.
The environments view will have 2 tabs: available
and stopped
Plus we will add a stop environment button there:
Inside a environment.. the individual view, example link
We get rid of the "detroy" button all together, closing #22770 (closed) and replace it with stop
As for the builds list, this needs the stop environment button as well:
If you fix https://gitlab.com/gitlab-org/gitlab-ce/issues/22642 as well, we can immediately get rid of the manual
tag as well!
Any other edits are part of https://gitlab.com/gitlab-org/gitlab-ce/issues/22774
Links / references
- Builds on Review App creation: https://gitlab.com/gitlab-org/gitlab-ce/issues/21971
- Proposal from: https://gitlab.com/gitlab-org/gitlab-ce/issues/21971#note_15101346
- Meta issue for Review Apps: https://gitlab.com/gitlab-org/gitlab-ce/issues/20255