Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

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.

question from:https://stackoverflow.com/questions/66049966/azure-devops-release-task-to-deliberately-stop-the-release

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

enter image description here

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.

enter image description here

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...