Lesstep
Azure Pipelines · output variables · Checked November 10, 2026

Azure Pipelines: an output variable is empty in the next job or stage

A script sets a variable with echo "##vso[task.setvariable variable=myVar]...", and the next job or stage reads nothing, or the text $(myVar) itself: a macro whose variable does not exist stays as it is. By default the variable reaches only the later steps of the same job. Each step further away needs one more thing, and a missing one gives an empty value, not an error.

Set it once, with a step name

- job: A
  steps:
  - bash: echo "##vso[task.setvariable variable=myVar;isOutput=true]42"
    name: setVar

When that pipeline is a pull request's build validation: Azure DevOps Pull Requests, a plugin for JetBrains IDEs, lists the pull request's branch policies with their state in IntelliJ IDEA, Rider or PyCharm, and with Pro runs a failed build policy again once the pipeline is fixed. Its Pipelines tab (version 1.0.86 and later) lists the runs of the repositories you have open and opens a failed task's log in the editor, free to read.

Read it from where you are

Where you read itWhat you write
A later step, same job$(setVar.myVar) (without isOutput: $(myVar))
Another job, same stagedependsOn: A and, under variables:, v: $[ dependencies.A.outputs['setVar.myVar'] ]
A job in another stageThe stage dependsOn the first one, and v: $[ stageDependencies.One.A.outputs['setVar.myVar'] ]
A stage's conditioneq(dependencies.One.outputs['A.setVar.myVar'], '42'): the job name comes inside the quotes
From a deployment job (runOnce)dependencies.A.outputs['A.setVar.myVar']: the job name twice; with a resource, 'Deploy_VM1.setVar.myVar'

From Microsoft's pages on setting variables in scripts, variables, expressions and deployment jobs. Stages and jobs here are named One and A.

Why it is still empty

Similar pages

Azure DevOps pull requests in IntelliJ IDEA, Rider and PyCharm

Azure DevOps Pull Requests, a plugin by Lesstep for JetBrains IDEs 2024.1 or later and Android Studio, reads the organization, project and repository from your git remote and lists the pull requests that wait for your review in an IDE tool window, on Azure DevOps Services and on Azure DevOps Server. It shows the branch policies of a pull request with their state, so a required build that has not passed is next to its pull request, and with Pro you run a failed or expired build policy again from there. The review inbox is free; voting, commenting, completing and creating are Pro, with a 30-day trial.

Get it on JetBrains Marketplace

Azure DevOps and Azure Pipelines are trademarks of Microsoft Corporation; IntelliJ IDEA, Rider and PyCharm are trademarks of JetBrains s.r.o. This page is not affiliated with or endorsed by Microsoft or JetBrains.

More: ##_vso[ in the log · The step name appears more than once · A template expression is not allowed in this context · Build validation · 日本語