简体   繁体   中英

Azure DevOps Release Task to deliberately stop the Release

I'm trying to find a release task that I can place inside a Release Pipeline Stage's workflow to intentionally stop the Release.

I have a large provisioning pipeline with 50 tasks per Stage (and 6 Stages). Barring a few exceptions the Stages are identical in Tasks, only differing with variables.

After the 10th task if a variable is true, then I want to stop the Release. This is not a failed Release (so I don't want to mark the Release as failed), it just means after the 10th task there is legitimately nothing more to do.

I see lots of information saying create a condition on an existing Task so that the Task only runs when the condition evaluates to true.

This Microsoft documentation suggests to me that on Tasks 11 to 50 I would need a custom condition that says "only run if variable = true". I might have misunderstood the behaviour and there might be another way to achieve the same result.

Why do I want a Task and not a Condition?

Conditions seem to cater for pre-conditions, not post-conditions scenarios. If it has to be a condition I'd rather say, "stop the release successfully after the 10th task has completed successfully and the variable = XYZ" using a post-condition such as:

eq(variables['RunTasks11To50'], 'True')

This is a pain to do this 40 times for a pre-condition (11th task onwards) and it is also error prone as the condition is not obviously set without drilling into the task (unlike a disabled task which is greyed out).

  • If there was a "Stop Release" task that allows the Release to legitimately stop then I wouldn't need to add conditions on Tasks 11 to 50.
  • Alternatively maybe if there was a "Gate" task that allowed the release to pause and require a confirmation to continue that might work too.

My concern is that I'm going to need to write a condition eq(variables['RunTasks11To50'], 'True') on 40 tasks multiplied by 6 stages (6 environments).

What have I considered?

  • Writing a Powershell task to call the DevOps Rest API to cancel my own Release
  • Somehow disabling the Tasks 11 to 50 at runtime (again probably requiring a Powershell Task DevOps Rest API call)
  • Wondering if I'm looking for a complicated answer when there's something obvious and simple I've missed.

Thanks for any advice.

Unfortunately, there is no "Gate" task to stop the release.

Alternatively maybe if there was a "Gate" task that allowed the release to pause and require a confirmation to continue that might work too.

We could set Post-deployment conditions or Pre-deployment conditions to add Approvers.

在此处输入图像描述

We recommend that you using condition on Tasks 11 to 50 in the release pipeline and use condition on Stage2 to Stage6 to skip the stage task.

在此处输入图像描述

Also, we could add task power shell tp call the REST API to cancel the release.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM