我想通过 REST API 触发特定的 Azure 管道。 我已经检查了 this documentation 。所以核心信息是:
curl -x POST $username:$personalaccesstoken https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1
在这里,我无法在 azure devops 中的任何位置找到 $pipelineId。
我尝试使用 REST API 获取 Pipeline,但答案没有给我 pipelineId。我尝试使用 az pipelines create
创建管道以获取结果中的 pipelineId,但它一直要求我 az 登录,尽管我一开始 az 登录成功:
Before you can run Azure DevOps commands, you need to run the login command(az login if using AAD/MSA identity else az devops login if using PAT token) to setup credentials. Please see https://aka.ms/azure-devops-cli-auth for more information.
我检查了this post,但它没有给出答案。
老实说,如果您对如何查找 pipelineId 或任何其他方法来使用 REST API 触发管道有任何想法,我们非常欢迎您!
最佳答案
pipelineId
等于 definitionId
因此,请转到您的管道并检查如下网址 https://dev.azure.com/thecodemanual/DevOps%20Manual/_build?definitionId=177
。
或者使用此端点来获取定义列表:
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/definitions?api-version=5.1
关于azure - 如何通过rest api触发azure管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64930191/