We are using Azure Pipelines (YAML not classic) for both build & releases. The stages are as follows:
The YAML is parameterised that user can select what stages to run. For example:
Now problem arises in scenarios like below:
runVersion: 'latestFromBranch') >> Outcome: works because last build Id produced artifact and deployment was successfulrunVersion: 'latestFromBranch') >> Outcome fails, because the very last deploy job to SIT didnt produce any artifact.I dont know if its a bug or shortcoming of this pipeline task, but would expect the DownloadPipelineArtifact@2 tasks refer to the very last build Id of the branch that produced the artifact. It seem from the logs that DownloadPipelineArtifact@2 task simply tries to download artifact from very previous pipeline run which may not have produced any artifact.
Its very normal during any project to run 1 build & and then deploy that build over time to various environment (promoting artifact). So pipeline stages per run would look like:
Can someone advise if this is a shortcoming of the task or am I doing something wrong?
Below is my task configuration:
- task: DownloadPipelineArtifact@2
displayName: Download LATEST artifact
inputs:
buildType: 'specific'
project: '$(System.TeamProjectId)'
definition: '$(System.DefinitionId)'
runVersion: 'latestFromBranch'
branchName: '$(Build.SourceBranch)'
targetPath: '$(Pipeline.Workspace)'
"DownloadPipelineArtifact" task with 'specific' buildType checks the last successful build in the pipeline, if there is no artifact produced in the last successful build, you would get "Artifact art was not found for build xxx". This is how "DownloadPipelineArtifact" task works.
To solve your issue, there are two ways:
For every pipeline run, you run two stages (Build + Deployment), then set 'current' buildType for "DownloadPipelineArtifact" task. In this way, you could always get the latest artifact, and I recommend this way.
Add "PublishPipelineArtifact" task in each Deployment stage, so that there always have artifact in the pipeline run.
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'specific'
project: '94eb5b0e-78fd-4ec0-a3c5-62d5becb6c0f'
definition: '119'
buildVersionToDownload: 'latest'
artifactName: 'A.A'
targetPath: '$(Pipeline.Workspace)'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)/A.A'
artifact: 'A.A'
publishLocation: 'pipeline'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With