0
votes

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:

  • Splitting the tasks into multiple jobs with the task group depending on a manual intervention task.
    • does not work, if the manual intervention is rejected the whole execution stops with failed.
  • Splitting the tasks into multiple stages doing almost the same as above with the same outcome.
  • Splitting the tasks into multiple stages trigger every stage manually.
    • not very usable because you have to execute what you want in the correct order and after the previous stages succeeded.
  • Variable set at release creation (true/false).
    • Will use that if nothing better comes up but kinda prone to typos and not very usable for the colleagues who will use this. Unfortunately Azure DevOps seems to not support dropdown or checkbox variables for releases. (but works with parameters in builds)
  • Two Stages one with tasks 1,2,3,4 and one with tasks 1,3,4.
    • not very desireable for me because of duplication.

Any help would be highly appreciated!

3
I think setting true/false at release creation time is the best path. Probably with a default value for true/false, so, it is kind of obvious how to override it. It is freeform, but at some point, is it really worth it to hack your pipeline because someone can't figure out how to type true/false correctly. If it is really an issue, I'd say you could build some kind of front-end that calls the release API. That is what I have done in the past for complex options.Matt
thx for your response! Currently I have it exactly like that with default to false. I just wanted to know if I'm on the right way or if there is a better option for this requirement. It would be great to have the possibility do define variables as bool/list or whatever, so the users can choose the possbile values instead of having to type them correctly. I'll keep your idea with a custom front-end and API calls in mind it could help me with other requirements too (with which I'm not already frustrated enough to write a stackoverflow question for them)bego

3 Answers

1
votes

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.

1
votes

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.

0
votes

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!