In this post let's see how we can use Parameters in a Task Group to control
Task execution in Azure DevOps Classic Release Pipelines.
Let's say we have a Task Group that accepts following parameter.
|
Task Group Parameter |
Now based on the value (true/false) passed in for this parameter, say I want
to skip a particular Task. For that, we can use tasks
Control Options ->
Run this task ->
Custom conditions.
|
Control Options -> Run this task -> Custom conditions |
First step is initializing a release level variable with the value of the
parameter.
Note: I couldn't figure out how to access parameters directly in the condition, hence using a variable. If you find out a way, please do leave a comment.
We can add in a PoweShell Task and do follows to initialize a variable.
Write-Host "##vso[task.setvariable variable=varIsSkipTask]$(IsSkipTask)"
|
Set Variable |
And now, we can use the variable in custom condition as follows.
and(succeeded(), ne(variables['varIsSkipTask'], 'true'))
|
Control Options -> Run this task -> Custom conditions: Skip Task |
And that's it.
Now when I run a release with IsSkipTask = true ,
|
IsSkipTask = true |
Task is Skipped.
|
Task is skipped |
Else,
|
Task is not skipped |
Task is not getting skipped.
Hope this helps.
Happy Coding.
Regards,
Jaliya
No comments:
Post a Comment