Workflows/Jobs/etc… are stateful processes that can have any number of open resources.
These resources need to be closed whenever the job/workflow that contains it is closed, no matter what the circumstances, and
especially on cancellation. There are a number of open tickets on this.
Currently, if a build is cancelled (manually or via auto-cancel), the test post hook command doesn’t run. So if you need to do any clean up, it will not occur.
In our specific case, we’re using SauceLabs’ sauce connect binary to create a tunnel to CircleCI for selenium testing our feature specs. We pay per tunnel. When a build starts a tunnel per parallel process is opened, but if that build is cancelled, the test/post command to kill the tunnel doesn’t run and the tunnel just stays open until …
I want certain actions to always execute at the end of a build, regardless of if failed or at what stage it failed. Currently there is a teardown stage but it only runs the CircleCI specific actions as opposed to the ones specified in the pre: section.
This would help support scenarios such as sending metrics at the end of a run (see
How can I collect metrics from CircleCI?) or ensuring proper shut down of certain processes (such as SauceConnect, see https://github.com/circleci/sau…
It’s useful to have cleanup stanza. This can be done with when: always. However, this is not done whenever the build is cancelled. It would be useful to also allow a when: cancelled.
None of which has any response. What’s the status?
Sounds like a good hook to have. Have a look at
circleci.com/ideas to see if it has been proposed already - and if not, please do add an idea. The forum does not automatically funnel ideas into the pot, as far as I know.