user2750828
user2750828

Reputation:

Azure DevOps Releases skip tasks

I'm currently working on implementing CI/CD pipelines for my company in Azure DevOps 2020 (on premise). There is one requirement I just not seem to be able to solve conveniently: skipping certain tasks depending on user input in a release pipeline.

What I want: User creates new release manually and decides if a task group should be executed.

Agent Tasks:

 1. Powershell
 2. Task Group (conditional)
 3. Task Group
 4. Powershell

What I tried:

Any help would be highly appreciated!

Upvotes: 1

Views: 10911

Answers (3)

user2750828
user2750828

Reputation:

Finally I decided to stick with Releases and split my tasks into 3 agent jobs. Job 1 with the first powershell, job 2 with the conditional taskgroup that executes only if a variable is true and job 3 with the remaining tasks.

As both cece-dong and dreadedfrost stated, I could've achieved a selectable runtime parameter for the condition with yaml pipelines. Unfortunately one of the task groups needs a specific artifact from a yaml pipeline. Most of the time it would be the "latest", which can be easily achieved with a download artifacts task but sometimes a previous artifact get's chosen. I have found no easy way to achieve this in a way as convenient as it is in releases where you by default have a dropdown with a list of artifacts.

If found this blog post for anyone interested on how you can handle different build artifacts in yaml pipelines.

Thanks for helping me out!

Upvotes: 0

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31083

Unfortunately, it's impossible to add custom condition for a Task Group, but this feature is on Roadmap. Check the following user voice and you can vote it:

https://developercommunity.visualstudio.com/idea/365689/task-group-custom-conditions-at-group-and-task-lev.html

The workaround is that you can clone the release definition (right click a release definition > Clone), then remove some tasks or task groups and save it, after that you can create release with corresponding release definition per to detailed scenario.

Upvotes: -1

DreadedFrost
DreadedFrost

Reputation: 2978

Depends on what the criteria is for the pipelines to run. One recommendation would be two pipeline lines calling the same template. And each pipeline may have a true/false embedded in it to pass as a parameter to the template.

The template will have all the tasks defined in it; however, the conditional one will have a condition like:

 condition: and(succeeded(), eq('${{ parameters.runExtraStep}}', true)) 

This condition would be set at the task level.

Any specific triggers can be defined in the corresponding pipeline.

Here is the documentation on Azure YAML Templates to get you started.

Upvotes: 1

Related Questions