I have a deployment pipeline that uses a build pipeline as a resource. I want to be able to select the build version to use when I manually run the deployment but the run ignores any version I select in the resource version picker and simply uses the latest. What am I missing?
I select the previous build which has an id of 8517. But in the logs it shows it is downloading the current build with id 8528.
This is the deployment pipeline:
trigger:
- none
resources:
pipelines:
- pipeline: Console
source: Build.Console
extends:
template: Deploy.yml
parameters:
...
The template it uses is pretty simple:
parameters:
...
jobs:
- deployment: Console
workspace:
clean: outputs
environment: 'Test'
strategy:
runOnce:
deploy:
steps:
- download: Console
...
The documentation seems to imply this is straight forward.
In researching this I've only found discussions on the picker being available as of 2020 and using it like I have above. I haven't found any discussion on it not working other than questions like this, but his solution is what I'm already doing.
Originally I was thinking the issue was related to the use of triggers in the resource definition because the doc mentions that triggers will always use the triggering resource ("used only for manual or scheduled triggers."), but even simplifying it down to only the source pipeline as above doesn't let the run use the selected version.
The only got'cha I can think of is I'm using the download
step instead of a task. The template is used by a triggered release pipeline for another environment and that works well, so I'm reluctant to modify it to use the DownloadPipelineArtifact
task with the buildType: specific
settings.
I've tried cleaning the entire workspace as Miao Tian-MSFT suggested with not luck.
I've looked at specifying the version explicitly using a variable but there are two issue with it. First, it doesn't appear to be an option to use a variable in the resource declaration. Second, the version id variables are determined by the resources:
section and so wouldn't be available to use for a version:
property inside that section.
I tested the deployment pipeline and template you shared, I found it works in my pipeline when I use workspace: clean: all
in the Template Deploy.yml.
It is mentioned here:
When you specify one of the clean options, they're interpreted as follows:
outputs
: DeleteBuild.BinariesDirectory
before running a new job.resources
: DeleteBuild.SourcesDirectory
before running a new job.all
: Delete the entirePipeline.Workspace
directory before running a new job.
When you download the pipeline resources with download: Console
, it will download artifact to $(Pipeline.Workspace)\Console
. So, we need to clean all to clean the Pipeline.Workspace
directory.
My sample:
Deployment pipeline:
trigger:
- none
pool:
vmImage: windows-latest
resources:
pipelines:
- pipeline: Console
source: one
extends:
template: Deploy.yml
Template Deploy.yml:
jobs:
- deployment: Console
environment: 'myEnvironment'
workspace:
clean: all
strategy:
runOnce:
deploy:
steps:
- download: Console
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Pipeline.Workspace)\Console'
ArtifactName: 'drop'
publishLocation: 'Container'