Azure DevOps stage output variables - three things that silently do not work
I needed one stage to compute something and later stages to condition on it. Azure DevOps supports this. It also fails silently in three specific ways, and none of them produce an error message that points at the cause. Nothing Fabric-specific here. This applies to any multi-stage pipeline. Setting the variable - stage : DetectChanges jobs : - job : Detect steps : - script : python…
Three critical issues can silently break Azure DevOps multi-stage pipelines, with no error messages to pinpoint the cause. This applies to any pipeline with multiple stages. The problems involve setting output variables, referencing them in conditions, and correctly specifying dependencies.
Firstly, output variable values are treated as strings, making conditions like eq(dependencies.DetectChanges.outputs[ Detect.detect.ved ], true) always evaluate to false. This leads to skipped stages and green pipelines, as skipped stages are not considered failures.
Secondly, referencing an output variable requires specifying all three parts: stage .outputs[ Job . StepName . Variable ]. If any part is missed, the variable cannot be accessed, resulting in an empty value instead of an error. Moreover, the step name is not the displayName, and if the step lacks a displayName, its variable becomes unreachable.
Lastly, the stage consuming the output variable must declare the dependency using dependsOn. Without this, the variable will not resolve, and the condition will evaluate to false. However, no error or warning is generated, and the stage appears to have run successfully, presenting a green pipeline that did nothing.
All three issues share a common cause: they each produce an empty string, which compares false, causing the stage to skip. This results in a green pipeline that accomplished nothing, worse than a red one as it provides no indication of the issue. To debug these problems, print the set variable in the producing job and publish it as a build artifact, creating a durable record of the decision made by the detection script.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.