【发布时间】:2020-08-30 05:49:08
【问题描述】:
我正在尝试使用他们的 REST api 为特定分支自动创建 Azure Pipelines。
但是,我很难使用他们几乎所有的 API,因为他们的文档缺少示例。
List 和 Get 之类的东西很简单。
但是,在对构建进行排队时: https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-6.0
POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=6.0
{
"parameters": <parameters>, // how do i send paramters
"definition": {
"id": 1
},
"sourceBranch": "refs/heads/feature/my-pipeline",
"sourceVersion": "d265f01aeb4e677a25725f44f20ceb3ff1d7d767"
}
我目前正在努力发送参数。 我试过了:
类似的简单 JSON:
"parameters": {
"appId": "bab",
"platform": "android",
"isDemo": true
}
和字符串化的 JSON 版本,如:
"parameters": "{\"appId\": \"bab\",\"platform\": \"android\",\"isDemo\": true}"
但似乎没有一个工作。
它一直给我错误:
{
"$id": "1",
"customProperties": {
"ValidationResults": [
{
"result": "error",
"message": "A value for the 'appId' parameter must be provided."
},
{
"result": "error",
"message": "A value for the 'platform' parameter must be provided."
},
{
"result": "error",
"message": "A value for the 'isDemo' parameter must be provided."
}
]
},
"innerException": null,
"message": "Could not queue the build because there were validation errors or warnings.",
"typeName": "Microsoft.TeamFoundation.Build.WebApi.BuildRequestValidationFailedException, Microsoft.TeamFoundation.Build2.WebApi",
"typeKey": "BuildRequestValidationFailedException",
"errorCode": 0,
"eventId": 3000
}
文档非常不清楚如何发送这些数据:https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-6.1#propertiescollection
非常感谢您的帮助。
【问题讨论】:
-
在文档中它说它是一个字符串,所以我会尝试使用类似这样的参数:“appId=xxxxx platform=xxxx isDemo=xxxxx”,这就是我发送变量的方式使用 Azure Cli for powershell 构建,在该文档中它就像这样一个字符串。试试看!!
-
刚刚尝试过:
appId=test platform=android isDemo=true,但也出现错误。
标签: azure azure-devops azure-pipelines azure-rest-api