![](/img/trans.png)
[英]How do you specify the FullyQuailifiedName in an Item Query via the QuickBooks-online API SDK
[英]How do you specify the sourceBranch for a Run of Pipelines via the REST API?
我一直在嘗試為我正在使用的存儲庫的特定分支運行管道。
在 UI 中,有一個方便的選項,但我不明白在請求中要嘗試什么。
無論我做什么,我總是逃避主人。
我該如何改變呢? 我嘗試填寫存儲庫參數但無濟於事: https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run%20pipeline?view=azure-devops-rest- 6.0#repositoryresourceparameters
這是一個示例請求:
curl --location --request POST 'https://dev.azure.com/<redacted>/<redacted>/_apis/pipelines/<redacted>/runs?api-version=6.0-preview.1' \
--header 'Authorization: Basic <redacted>' \
--header 'Content-Type: application/json' \
--header 'Cookie: VstsSession=<redacted>' \
--data-raw '{
"previewRun": true,
"resources": {
"repositories": {
"refName": "refs/heads/<redacted>"
}
},
"runParameters":
{
"namespace" : "<redacted>",
"image" : "<redacted>",
"tag" : "<redacted>",
"package" : "<redacted>",
"version" : "8.4.4"
}
}'
從您的屏幕截圖中,您似乎正在使用 YAML 管道。
我已經測試了你的例子,這個問題的根本原因是請求正文(data-raw)有一些問題。
你可以試試我的樣品
curl --location --request POST 'https://dev.azure.com/<redacted>/<redacted>/_apis/pipelines/<redacted>/runs?api-version=6.0-preview.1' \
--header 'Authorization: Basic <redacted>' \
--header 'Content-Type: application/json' \
--header 'Cookie: VstsSession=<redacted>' \
--data-raw '{
"stagesToSkip":[],
"resources":
{
"repositories":
{
"self":{"refName":"refs/heads/{Branchname}"}
}
},
"templateParameters":
{
"namespace":"{value}",
"image":"{value}",
"tag":"{value}",
"package":"{value}",
"version":"{value}"
},
"variables":{}
}'
結果:
對於 Http 請求(可以用 Postman 測試)
1. Get pipeline api url like this https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=7.1-preview.1
填寫您的組織、項目和 pipelineId。 (當您在 Azure DevOps 中打開管道定義時,所有這些都可以在鏈接中找到)
2.添加基本認證頭
key: Authorization, value:"Basic [your azure Person Access Token from Azure Dev Ops with Access to Pipeline]"
應該看起來像這樣“基本 OndzNWdz43FKfjdi98hjKDJFH8kkg9854HJKHF9D8RFEHui4387lkNXE="
並將內容類型設置為 application/json
像這樣
鍵:內容類型,值:應用程序/json
3. 將此 JSON 放入原始機身
{ "templateParameters":{ "inputName":"johnsmith" }, "resources":{ "repositories":{ "self":{ "refName":"refs/heads/feature/#JIRATask01_Blabla" } } }, "variables":{ } }
將 refName 值替換為您要為其運行管道的分支。
如果您有多個 repo 管道,請查看此主題(但我尚未測試該解決方案): Azure DevOps API to Trigger Multi Repo changes branches
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.