4

In Azure DevOps classic pipelines you can have a build pipeline for creating the artifact and a release pipeline for deploying it. This means that whatever stored prexisting artifact could be deployed simply launching the release pipeline and selecting the artifact´s version (typical usage: rolling back the current deployed artifact to a previous version)

How this can be achieved in Multi-Stage pipeline? Any way of launching only the deployment stage selecting the artifact to be deployed?

Regards

Josto
  • 137
  • 11

2 Answers2

1

How this can be achieved in Multi-Stage pipeline? Any way of launching only the deployment stage selecting the artifact to be deployed?

Indeed, this is very convenient to choose prexisting artifact based on actual demands, but what you want does not supported in Multi-Stage pipeline until now.

This request already reported to the MS product team:

Select artifacts in YAML release pipeline

This feature have been added in the last sprint:

Pipeline resource version picker in the create run dialogue

However, as I test, it seems this feature has not been deployed in all regions:

enter image description here

If it not deployed in your region, you could try to use the task Download Pipeline Artifacts task with the runId input:

- task: DownloadPipelineArtifact@2
  inputs:
    source: 'specific'
    artifact: 'drop'
    path: $(Build.SourcesDirectory)/bin
    project: 'AndroidBuild'
    pipeline: 12
    runVersion: 'specific'
    runId: $(buildid)

Then use pass queue variable buildid when we queue the build:

enter image description here

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
0

This can be done by having two pipelines. one pipeline for your build where your pipeline produces an artifact and create another pipeline for your release stages. In the release pipeline, you can set the resources to point to another build or pipeline. where you can consume your previously produced artifact(including older build version) to deployment stages.

See: YAML Resources

Your release YAML pipeline can specify what resources it needs. You can specify an existing build or another pipeline.

resources:
  pipelines:
  - pipeline: SmartHotel-resource # identifier for the resource (used in pipeline resource variables)
    source: SmartHotel-CI # name of the pipeline that produces an artifact

However, Keeping them separate just leads to move overhead and maintenance.

Auto geek
  • 464
  • 1
  • 6
  • 21
  • Thank you @auto-geek. Only one pipeline would mean to build again the artifact from sources in case of rollback to a previous version. Would be this one your approach? – Josto Feb 18 '21 at 11:20
  • Yes, having everything in one pipeline would mean you have to build again when rolling back to the previous version, as your release stages would require the artifact to consume. you can't skip the build stage nor you can choose the old build version with a single pipeline approach. The workaround is to divide your pipelines into 2 parts and choose whatever build artifact that works for you in the release pipeline without running build again. @Josto – Auto geek Feb 18 '21 at 14:12