I have set up a pipeline which deploys to QA and PROD environments, with a pre-deployment approval before going to PROD. I tried to set up the pipeline so that if another release is sent through before the approval happens, it will cancel the prior release with pending approval. I used the "Deploy latest and cancel the others" option in Deployment Queue Settings for the first step/stage. However, this doesn't seem to have any effect.
At first I thought it was just because of the pending approval. But I did some additional tests and found that, even if the release is running and not awaiting approval, it is not canceled. I suspect this is because it is designed to only cancel queued releases and not ongoing releases. But if that is so, is it possible to cancel a release that is in progress if a new one comes behind it?
FYI I already checked this answer, but as I mentioned, is is not cancelling in progress releases (though for some reason it seems to work in this exact use case for that OP).
Ultimately, I just want to replace a pending release if a newer release is created before it finishes. Please let me know if there is a way to do this?
Edit: Just to clarify on the accepted answer, there were two issues. In my first runs, I didn't have Deploy latest and cancel the others
checked on every stage, so that particular stage was not cancelling. Then after checking this option, it wasn't working because I wasn't letting the pipeline run to the same stage, rather I was cancelling the new release after I saw the old one didn't immediately cancel. I was under the impression that the release would be cancelled immediately, but it's not until the new release gets to the same stage that the old stage awaiting approval would be cancelled. Once I let the pipeline run through, the pending approval stage cancelled as expected. So really, that option seems to be tied to the stage, not to the entire release. Just wanted to provide some additional context to the answer.