azure - 如何通过rest api触发azure管道

标签 azure azure-devops azure-pipelines azure-devops-rest-api

我想通过 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/

相关文章:

azure - 在用于 .NET Core 应用程序构建的 Azure DevOps 管道模板中使用 'parameters' 部分时出现“预期映射”语法错误

azure - 如何判断Azure Function App是否会重新启动?

azure - 如何通过 Azure DevOps API 更改拉取请求的目标

git - VSTS 生成关联的提交

windows - 如何授予 Azure Devops 私有(private) Windows 代理访问 SupportedAPIs-x64.xml 的权限?

azure - 是否可以将 "V2"存储帐户降级为 "V1"?

android - Azure -> Node.js 中的 Easy api -> 如何发送 Android 推送通知?

c# - .net5 上的函数 : No job functions found. 尝试将您的作业类和方法公开

azure - 如何在 Azure DevOps Pipelines 上批量更改审批者?

mysql - Azure 上具有不同关联组的数据库同步