'AzureDevOps-YML-pipeline Get PublishBuildArtifacts URL in yml pipeline

Is there any possibility to get the URL of a published artifact in the yml pipeline, so it can be used in further pipeline tasks/steps?

Sadly, the Microsoft Docs on the two tasks don't give any hints if the published path value is available in any way.

- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: report.html
    artifactName: HtmlReport


Solution 1:[1]

It depends on where you're using the artifacts - Deployment jobs will typically automatically download the artifacts into the $(Pipeline.Workspace) folder with the same name as you declare in the build task.

So in your case it would be located at $(Pipeline.Workspace)\HtmlReport

You can also use the Download Build Artifacts task to download a specific artifact:

- task: DownloadBuildArtifacts@0
  inputs:
    buildType: 'current'
    downloadType: 'single'
    artifactName: 'HtmlReport`

This is useful if you have multiple published artifacts and you only want to download one of them in a later stage. There are other options if you wish to download an artifact from a different pipeline.

Note that the Publish Build Artifacts task is now deprecated and you are recommended to use the newer Publish Pipeline Artifacts and matching Download Pipeline Artifacts tasks:

We recommend upgrading from build artifacts (PublishBuildArtifacts@1 and DownloadBuildArtifacts@0) to pipeline artifacts (PublishPipelineArtifact@1 and DownloadPipelineArtifact@2) for faster performance.

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