0
votes

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.

1

1 Answers

1
votes

I suspect this is because it is designed to only cancel queued releases and not ongoing releases.

Yes, your suspect is correct. It can only cancel the queued releases, but not the in progress one.

Also, this option still work fine for me at present. Not sure how do you configure this option on your side. For me, I set Maximum number of parallel deployments as 1 while the option Deploy latest and cancel the others is selected.

Then you will see the canceled releases display such message:

enter image description here


Ultimately, I just want to replace a pending release if a newer release is created before it finishes.

If the pending release means the one which is pending on approval, you can still make use of Deploy latest and cancel the others option to achieve that.

But if it represent the in progress one, I'm afraid it does not supported now. You can think about this design from the perspective of the product actual use. For example, there has other release are currently being deploy while a new release is ready for deployment. If we interrupt the ongoing deployment process suddenly, I think it is bad for product stability, which is why we can only cancel the queued release, not the one being deployed.