I have an Azure DevOps pipleline with one stage that is dependant upon two others. This stage should run conditionally if both of the following are true -
- Stage 1 (Deploy_BVT_UKS_Internal) sets an output variable with a specific value in one of it's jobs.
- Stage 2 (Test_BVT) either failed or was skipped.
Here is the condition that I am using. However, it is not working and the stage is being skipped when I expect it to run. The syntax for checking the value of the output variable was taken from the documentation.
condition: >-
and(
in(dependencies.Test_BVT.result, 'Skipped', 'Failed'),
eq(dependencies.Deploy_BVT_UKS_Internal.outputs['Swap_Slots.Output_Slot_Swap_Success_Variable.slotSwapped'], 'true')
)
To confirm, I'm formatting the output variable check as follows -
dependencies.<stageName>.outputs['<jobName>.<taskName>.<variableName>']
If I simply use in(dependencies.Test_BVT.result, 'Skipped', 'Failed')
as my condition then the stage runs if the Test_BVT
stage is skipped or fails. So this suggests that the output variable check is the issue, though I can't be as logs no longer seem to show how conditions are evaluated.
Confusingly the same documentation shows stage dependencies formatted in two different ways, so I have added a task to write the value of the output variable using both formats. The format that uses stageDependencies
produces the expected result, proving that the output variable is being set as expected. However, the format that uses dependencies
does not work.
- job: test
variables:
one: $[dependencies.Deploy_BVT_UKS_Internal.outputs['Swap_Slots.Output_Slot_Swap_Success_Variable.slotSwapped']]
two: $[stageDependencies.Deploy_BVT_UKS_Internal.Swap_Slots.outputs['Output_Slot_Swap_Success_Variable.slotSwapped']]
steps:
- script: |
echo $(one)
echo $(two)
displayName: Output SlotSwapped Value
I did try the stageDependencies
format in my condition, just in case, but that also failed.
Am I missing something here, or does this just not worked as documented?
dependencies
level and on the job levelstageDependencies
to refer to previous stages – Krzysztof Madej