1

I am writing an automated test suite using powershell and the az cli. I need to be able to download the build pipeline artefacts from the last run of the pipeline to install and test the application. The problem is I need to know the run ID to be able to download the artefacts.

az pipelines runs artifact download --artifact-name "*Artifact Name*" --run-id **nnn** --path "c:\temp"

Is there anyway to find the last successful run ID? At present I look it up through the GUI so I know the download works as long as you use PublishPipelineArtifact and not PublishBuildArtifact due to a bug in the az cli.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • az pipelines runs list . It also lists the status of the run among other details. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/runs?view=azure-devops – Aravind Apr 28 '20 at 11:39
  • I don't think you are supposed to use artifacts from previous runs. You would run into a problem when one run fails and doesn't create any artifacts. – renklus Apr 28 '20 at 15:26

2 Answers2

0

You can change how azure pipelines creates the run ID and use a predictable format. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/run-number

renklus
  • 776
  • 6
  • 17
0

One way is to use --output json then you can just iterate over the runs and look up the finishTime field:

az pipelines runs list --org $org --project $project --pipeline-ids $pipelineID --output json

enter image description here

I'm sure if you put in enough time there's probably a way using query strings to get latest as well.

Geordie
  • 1,920
  • 2
  • 24
  • 34