Environments for failed jobs
Problem to solve
We have a job that does some testing and then uploads a test report to an s3 bucket in the cloud in the after_script
section (hence also on failure).
The job then creates an environment with the url of the bucket so the report can be viewed directly from a merge request.
The problem now is that when the job fails gitlab doesn't create the environment and the url is not available from the merge request and also the on_stop action (deleting the folder from the bucket) does not get executed when the branch gets merged.
Proposal
add a when
configuration to environments similar to what is available for artifacts.
environment:
name: report/$CI_COMMIT_REF_SLUG
url: http://$AWS_BUCKET.s3-$AWS_REGION.amazonaws.com/$CI_COMMIT_REF_SLUG/html_report/index.html
on_stop: remove_report
when: always
Options for when
:
-
on_success
- default (current implementation) on_failure
always