Search code examples
azureazure-devopsazure-pipelinesazure-artifacts

Download pipeline artifact from another pipeline Azure


I'm very new to this pipeline and i'm trying to build a automated way to build the .msi installer file for my application.

I have 2 projects .Net Core and Python, so i created 2 pipelines. The .Net Core pipeline will build and save the files in a location and Python pipeline uses those files(from location) for its dependency and builds a new .msi file, the last portion in the pipeline newsetup.py builds the .msi to which i'll be passing the location of the output files of .Net Core pipeline.

The error i get is Artifact dropcli was not found for build 150.

.Net Core pipeline script:

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(Build.ArtifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    
- task: PublishPipelineArtifact@1
  inputs:
   targetPath: '$(Pipeline.Workspace)'
   artifact: 'dropcli'
   publishLocation: 'pipeline'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

Python pipeline script:

- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'current'
    artifactName: 'dropcli'
    targetPath: '$(Pipeline.Workspace)'

- task: PythonScript@0
  inputs:
    scriptSource: 'filePath'
    scriptPath: 'src/python/newsetup.py'
    arguments: 'bdist_msi $(Pipeline.Workspace)'

Also if i specify the build number somewhere won't it be an issue when a new pipeline is created? Or is that an limitation?


Solution

  • In your DownloadPipelineArtifact@2 task, the value of buildType is current. This means that you are downloading the artifact in the current run. You should set buildType to specific. Here is an example to download the latest artifact from a specific pipeline:

    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'specific'
        project: '{project id}'
        definition: '{pipeline id}'
        buildVersionToDownload: 'latest'
        artifactName: 'dropcli'
        targetPath: '$(Pipeline.Workspace)'
    

    You can click "Settings" at the top of the task, it will help you to complete your task more easily.

    enter image description here

    enter image description here

    Click Download Pipeline Artifacts task for detailed information about arguments of this task.

    If i specify the build number somewhere won't it be an issue when a new pipeline is created? Or is that an limitation?

    You don't need to specify the build number, and what you need to specify is the pipeline definition id. You can either download the latest artifact of a pipeline or the artifact of a specific build of a pipeline.