Reputation: 6467
I have a release pipeline for an asp.net 6 app which publishes the site to an IIS server. This release pipeline uses the artifacts published from the build pipeline. I link build pipeline to the release one
resources:
pipelines:
- pipeline: 'buildPipeline'
project: 'My Asp Net App'
source: 'Build pipeline'
branch: 'main'
What Im trying to achieve is to get the version of the build pipeline into the release pipeline. I used the following powershell task to check the version
- task: PowerShell@2
displayName: Version output
inputs:
targetType: "inline"
script: |
Write-Error "Build version is $(Build.BuildNumber)"
and is outputting the version of the release pipeline instead of the build. How can I get it without using any external sources.
Upvotes: 0
Views: 5415
Reputation: 35109
To get the Build version of the Pipeline resource, you can use the variable: resources.pipeline.<Alias>.runName
.
The variable: resources.pipeline.<Alias>.runName
will pass the variable: $(Build.BuildNumber)
of build pipeline to release pipeline via pipeline resources.
For example:
- task: PowerShell@2
displayName: Version output
inputs:
targetType: "inline"
script: |
Write-Error "Build version is $(resources.pipeline.buildPipeline.runName)"
Refer to this doc: Pipeline resource variables
Upvotes: 1