I am running jobs on a self-hosted Windows runner.
In one of my steps, I start a docker container that runs a long process inside it. When the job is cancelled, I want to immediately shut down the container and clean up after it.
I can tell that when I cancel the job, the container still keeps going until the process inside it is complete. This lingering docker also prevents any Circle CI job from starting.
I also know about requires: job canceled
condition for jobs in a workflow. However, this does not work for me because the running docker container prevents the runner from starting another job.
The one solution I can think of is detecting if the job was cancelled and then handling cleanup myself as part of the step that started teh container. However, I have not been able to find any way to detect that the job has been cancelled.
So, is it possible to detect if a job is cancelled, and handle it in the step? Or is there some other smarter way to clean up once the job is cancelled?