How to download artifacts in azure devops from a different repo into the current repo

88 Views Asked by At

I have written a azure pipeline named my-azure-pipelines.yml to download the artifacts published in a specific build.

I have used the following task in my pipeline to download the artifacts from a specific build.

- task: DownloadBuildArtifacts@0
  displayName: 'Download Artifacts'
  inputs:
    buildType: 'specific'
    project: 'YourProjectName'  # Replace with your Azure DevOps project name
    **definition: 'YourBuildPipelineName'  # Replace with the name of your build pipeline**(error)
    buildId: 'YourBuildId'  # Specify the build ID you want to download artifacts from
    downloadType: 'single'
    artifactName: 'YourArtifactName'  # Replace with the name of the published artifact
    downloadPath: '$(System.DefaultWorkingDirectory)/DownloadedArtifacts'

I am getting error which says ##[error]Definition name xyz didn't correspond to a valid definition

I am not sure what a build definition is and how to find it. Appreciate if somebody explains

I was expecting that the artifacts would be downloaded but due to the error the artifact are not getting downloaded

Error:

enter image description here

2

There are 2 best solutions below

0
wade zhou - MSFT On BEST ANSWER

There is no definition parameters for the task DownloadBuildArtifacts@0.

To fix the error, you can

  1. click on the settings(grey) link to simply pick the value for the parameters on the right side.
  2. Then click add button, it will automatically override with correct values.

enter image description here

After fix, it should look like below:

- task: DownloadBuildArtifacts@0
  displayName: 'Download Artifacts'
  inputs:
    buildType: 'specific'
    project: '1b60f1ab-xxxx3c91a6'
    pipeline: '330'
    buildVersionToDownload: 'specific'
    buildId: '2488'
    downloadType: 'single'
    artifactName: 'YourArtifactName'
    downloadPath: '$(System.DefaultWorkingDirectory)/DownloadedArtifacts'

In addition, if the artifact comes from another project, please go to Project settings -> Pipelines -> Settings -> Toggle off the option Limit job authorization scope to current project for non-release pipelines.

enter image description here

enter image description here

If the target build is in same project, the option above is not needed.

2
Shamrai Aleksander On

You may open the build which you are trying to use as an artifact source. Then check definitionId in the URL.

enter image description here