How to Set Pipeline-Level Variables in Azure Pipelines
A top-level variables block sets values every job and step in the pipeline can read.
Declare a variables block at the root of the pipeline. Reference values with $(Name) in scripts and inputs; they are available across all jobs and stages.
Declare and read pipeline variables
Set variables once at the top and reference them with the macro syntax.
azure-pipelines.yml
variables:
buildConfiguration: 'Release'
artifactName: 'webapp'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'Build'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/bin'
artifact: '$(artifactName)'Notes
- Use $(Var) for macro expansion at runtime; reserve ${{ }} for compile-time template expressions.
- For secrets, mark a variable secret in a variable group rather than putting it inline.
Related guides
How to Use a Template with Parameters in Azure PipelinesReuse pipeline logic in Azure Pipelines by defining a parameterized template and passing typed parameters whe…
How to Deploy to App Service in Azure PipelinesDeploy a web app to Azure App Service from Azure Pipelines with the AzureWebApp task using a service connecti…