Andreas
Andreas

Reputation: 2366

Unable to resolve $(Release.ReleaseId) in Azure DevOps yml pipelines

When using the Releases tab in Azure DevOps web console, to create release definitions, the tasks can resolve $(Release.ReleaseId) inside of a bash task.

But if I instead do my deployment in the azure-pipelines.yml file and do echo $(Release.ReleaseId), I get null because the variable doesn't exist. How come?

Here is part of the yml file

- stage: Deploy
dependsOn: BuildAndPublishArtifact
condition: succeeded('BuildAndPublishArtifact')
jobs:
- deployment: DeployToAWSDev
  displayName: My display name
  pool:
    vmImage: 'Ubuntu-16.04'
  environment: 'dev'
  strategy:
    runOnce:
      deploy:
        steps:
        - download: current
          artifact: MyArtifact

        - task: Base@3
          inputs:
            targetType: 'inline'
            script: |
              echo $(Release.ReleaseId) # Nothing

Thanks for any help to point in the right direction of how I can retrieve my release id.

Upvotes: 2

Views: 3801

Answers (1)

Daniel Mann
Daniel Mann

Reputation: 59037

Refer to the documentation on variables. There's no differentiation of "build" vs "release" in a YAML pipeline. Thus, Build.BuildId would be the run's ID.

Upvotes: 4

Related Questions