Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip or execute tasks/steps conditionally using TFS build?

I have a TFS build definition.

enter image description here

I wish to run two steps/task that execute two Command Lines, conditionally. Maybe with a variable I could set when I queue the build or something. Mainly I wish to run the build and skip some steps/task if I want to. How can I achieve this? Except making a bat file that executes my app.exe and sending a boolean variable to the bat script that will execute or not my app.exe.

like image 288
TBogdan Avatar asked Nov 28 '16 09:11

TBogdan


1 Answers

By adding a PowerShell Script task with Write-Host "##vso[task.setvariable variable=ExecuteMyTask]$(ExecuteMyTask)" before the task that needs to be executed conditionally, a new Process parameter named ExecuteMyTask is added to the Task Group that can be set to true or false (or left empty, to be set in the Build definition using this Task Group). In the 'conditional' task a Custom Condition and(succeeded(), eq(variables['ExecuteMyTask'], 'true')) can be added and the task will be executed conditionally.

This works on TFS.2018.2.

like image 133
Emiel Koning Avatar answered Sep 18 '22 13:09

Emiel Koning