Reputation: 561
So I am attempting to create a downstream project trying to use an artifact stored in azure pipeline artifact to build. I am using the task DownloadPipelineArtifact@0
It talks about the need for a pipelineId, not really sure where to find out the id for my other pipeline. Is there any easy way, its supposed to be a ~4 digit number according the documentation.
Thanks
Upvotes: 12
Views: 34562
Reputation: 1128
There are two IDs you may need to know in Azure Pipelines.
Build Pipeline ID / Definition ID: This is the ID of the Pipeline not a particular run of the pipeline. You can get it via System.DefinitionId
Build Record ID / Build ID: This is the ID for a particular run/record of your pipeline run. You can access it in your pipeline as Build.BuildId
In your case, you will need to use the Build.BuildId
since you are trying to get the artifact from a particular run of a pipeline.
Reference: Predefined Azure Pipeline Variables
Upvotes: 4
Reputation: 141
You can get pipeline ID from a pipeline directly from portal.
Upvotes: 9
Reputation: 581
The following command uses Azure CLI (with DevOps extension) and jq to get the pipeline id in Bash shell:
az pipelines show --name <PIPELINE_NAME> | jq -r .id
If you want to use this inside an Azure Pipeline, you need to use an Azure CLI task and probably install jq on the run agent.
See ultimatom's answer for how to set the id as a variable in the pipeline.
Upvotes: 1
Reputation: 11
I was facing the same problem in my azure devops pipelines, I don't know if it applies the same way for you, but here is my solution to do it :
There is the function az pipeline show that gives you the id of a pipeline with its name:
Pipeline_to_find="$1"
pipelineInfo=$(az pipelines show --name "$Pipeline_to_find")
id=$(echo "$pipelineInfo" | python -c "import sys, json; print(json.load(sys.stdin)['id'])")
#export this var to be used in any other task of your pipeline
echo "##vso[task.setvariable variable=id;]$id"
Upvotes: 1
Reputation: 12321
Go to the target pipeline you want -> Edit.
Check the URL. There you have the pipeline id.
.../_apps/hub/ms.vss-build-web.ci-designer-hub?pipelineId=1234&branch=main
I'm sorry I could not find a proper way to refer this without hardcoding.
Upvotes: 12
Reputation: 10910
There is an existing open issues on the pipeline ID.
The doc which you mentioned doesn't provide much information about pipelineID
.
As per microsoft
pipelineId
appears to beBuildId
, and not the build definition id. It needs the actual instance id of where the artifact is associated. I was able to make this work by referencing a release variable tied to the artifact alias. My alias is named "artifacts" and using$(RELEASE_ARTIFACTS_ARTIFACTS_BUILDID)
did the trick. So the format would be$(RELEASE_ARTIFACTS_<alias>_BUILDID)
If you were trying to consume in a build and not a release pipeline you would need to somehow get the value of
$(Build.BuildId)
I hope as this matures there are plans to make pipeline artifacts published from a build automatically in release, just like they are when using the old Build Artifacts. Currently for me that is not happening so I am forced to manually add this step to my release pipeline and associate it with the build pipeline.
Upvotes: 2