'Associate a build artifact in yaml release pipeline

In Azure Devops, I have two individual yaml pipelines one for build and another for release. I would want to link the build artifact in the yaml release pipeline ,like the one we have for classic pipelines. Is there anyway we can achieve the same for yaml release pipelines.

198982-release.png



Solution 1:[1]

I'm from the Microsoft for Founders Hub team. If you want to be able to access your artifact across different stages in your pipeline, you can use output variables to pass it to the next stage in your YAML. Please follow the below script.

trigger: none
pool:
  vmImage: 'ubuntu-latest'
stages:
- stage: A
  jobs:
  - job: A1
    steps:
     - script: echo ##vso[task.setvariable variable=shouldrun;isOutput=true]true
       name: printvar
- stage: B
  dependsOn: A
  jobs:
  - job: B1
    condition: in(stageDependencies.A.A1.result, 'Succeeded', 'SucceededWithIssues', 'Skipped')
    steps:
    - script: echo hello from Job B1
  - job: B2
    condition: eq(stageDependencies.A.A1.outputs['printvar.shouldrun'], 'true')
    steps:
     - script: echo hello from Job B2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Caney