I am trying to write an Azure DevOps YAML pipeline where I set the deployment environment dynamical in a predecessor job. Here is a conceptual example of what I am trying to do:
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: SetVariable
jobs:
- job: SetVariableJob
steps:
- script: |
echo "##vso[task.setvariable variable=environmentName;isOutput=true]TestEnvironmentName"
name: setvarStep
- stage: Deploy
dependsOn: SetVariable
variables:
environmentName: $[ dependencies.SetVariable.outputs['SetVariableJob.setvarStep.environmentName'] ]
jobs:
- deployment: DeployWeb
environment: $(environmentName)
strategy:
runOnce:
deploy:
steps:
- script: echo Hello, $(environmentName)!
Something is wrong, as the echo Hello, $(environmentName)! just outputs: Hello, !
azure-pipelines.ymlThere are three things to pay attention to