I have a build pipeline in Azure DevOps that is generating artifacts dynamically with $(Build.BuildId) as part of the artifact name. My pipeline creates backend and frontend artifacts, but when I push a new build, the release artifacts get selected inside the deployment group, and I have to manually select the artifacts again for the release pipeline to work properly.
trigger: none
pool:
name: Azure Pipelines
vmImage: 'windows-2022'
variables:
RestoreBuildProjects: |
**/Web.Api.csproj
BuildConfiguration: 'Release'
ConnectionStringDatabaseName: 'database'
DropFolder:
'$(Build.ArtifactStagingDirectory)/drop/$(Build.DefinitionName)/$(Build.BuildId)'
DropFolder:
'$(Build.ArtifactStagingDirectory)/drop/$(Build.DefinitionName)/$(Build.BuildId)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Backend Artifacts'
inputs:
PathtoPublish: '$(DropFolder)/My project.zip'
ArtifactName: 'myproject-backend-$(Build.BuildId)'
Every time a new build is triggered, a new artifact (e.g., myproject-backend-1221) is created, and my release pipeline automatically deselects the artifacts. I have to go into the release pipeline manually and re-select the correct artifact before I can proceed with the release.
How can I prevent the release pipeline from selecting the artifacts after each new build? Is it possible to ensure that the latest build artifacts are automatically selected without having to use dynamic artifact names?
I can reproduce the same issue when selecting part of the artifacts in release pipeline.
Here is an example:
Select the part of artifacts in release pipeline:
Create a new build to generate new artifacts: the artifacts will be deselected
It shows the message: Selected x/3 artifact(s). But it was not actually selected.
The issue is from the Azure DevOps Pipeline feature itself. I suggest that you can report the issue to Developer Community. Azure DevOps Developers will investigate this Product issue further.
For workarounds, you can use the option: Select all artifacts to download all artifacts. In this case, the release pipeline will not automatically deselect the artifacts after new artifacts generated.
For example:
Or you can add Download Build Artifacts task in Deployment group job and define the myproject-backend-$(Build.BuildId) in Artifact name field to download the target artifact with dynamic artifact names.