Reputation: 2673
I am very new to ADO pipelines in Azure. I have a situation where I have the build ID of a pipeline run that created an artifact. I need to download this artifact in a different pipeline. In order to use DownloadPipelineArtifact@2
you have to provide both the pipeline
an buildId
. the docs
In my case, I only have the buildId
and figured I could look up the pipeline via an az
command, like so:
- task: AzureCLI@2
displayName: lookup pipeline ID
inputs:
azureSubscription: $(ServicePrincipal)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
pipelineId=$(az pipelines runs show --id ${{ parameters.buildId }} --query "definition.id")
echo build ${{ parameters.buildId }} belongs to pipeline $pipelineId
echo "##vso[task.setvariable variable=pipelineId]$pipelineId"
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
This all works as expected, BUT when I run that same az
command from my local machine, it returns in < 1 second... When it runs in my pipeline, it takes closer to 1 minute.
what am I doing wrong (if anything) and what could I do to make this command happen faster?
UPDATE 1
Based on jessehouwing's answer, I updated my step like so (I'm on a Windows-hosted agent, not self-hosted):
parameters:
buildId: ''
steps:
- bash: |
pipelineId=$(az pipelines runs show --id $BUILD_ID --query "definition.id")
echo build $BUILD_ID belongs to pipeline $pipelineId
echo "##vso[task.setvariable variable=pipelineId]$pipelineId"
displayName: lookup pipeline ID
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
BUILD_ID: ${{ parameters.buildId }}
And it actually ran SLOWER,
So, while using bash still got me the data I needed, it didn't speed anything up.
UPDATE 2
so, I updated my lookup-pipeline
step as you suggested, but it had a typo....and the pipeline ID was never returned:
much to my surprise, the download step did not fail.... it actually downloaded the correct artifact. I tested a redeploy of an older build just to make sure it wasn't grabbing the "latest" build. Sure enough, from what I can tell....despite the docs saying otherwise, the pipeline
doesn't appear to be required when attempting to download an artifact from a pipeline in the same org. Therefore, I have eliminated the lookup step entirely and the entire pipeline works as expected.
Another tragic case of out of date MS docs
Upvotes: 0
Views: 2520
Reputation: 114751
There is a bug in the current hosted runner image which causes az cli
to discover all of the installed modules and extensions on the first call, because this data is lost in the provisioning process. This enumeration takes around 50s.
Update: A number of pull-requests are making their way to the public runners, the ones in green have already been deployed.
With these changes, first-call performance is now less than ~15s instead of ~60s or more on Windows.
I've captured all of my findings from the last week looking into this issue in an extensive blog article.
Upvotes: 5