gpt4 book ai didi

azure - 创建 azure devops 发布管道时出错 - POST Rest api

转载 作者:行者123 更新时间:2023-12-04 09:39:57 29 4
gpt4 key购买 nike

使用 powershell ADO Rest API 创建 ADO 发布管道时遇到问题。

下面是代码 -

[string]$organisation = "",
[string]$project = "",
[string]$keepForever = "true",
[string]$user = "",
[string]$token = "")

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$postresults = "https://vsrm.dev.azure.com/$organisation/$project/_apis/release/definitions?api-version=5.0"

$body = @{
"name"="New release pipeline russ"
"comment"="test"
"environments"=@{
"name"="DEV"

}
"path"="\\"
"releaseNameFormat"="Release"
"description"=""
} | ConvertTo-Json

$result = Invoke-RestMethod -Uri $postresults -Method Post -Body $body -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}

我得到的错误是 -


Invoke-RestMethod : {"$id":"1","innerException":null,"message":"VS402875:
Release pipeline needs to have at least one stage. Add a stage and try again.",
"typeName":"Microsoft.VisualStudio.Services.ReleaseManagement.Data.Exceptions.I
nvalidRequestException, Microsoft.VisualStudio.Services.ReleaseManagement2.Data
","typeKey":"InvalidRequestException","errorCode":0,"eventId":3000}
At line:27 char:1

在 VS 开发者社区博客中发现类似问题,不幸的是没有帮助 -

https://developercommunity.visualstudio.com/content/problem/582209/post-example-to-create-a-release-pipeline.html

非常感谢您的任何意见。

谢谢

最佳答案

正文中的环境应至少包含namepreDeployApprovalspostDeployApprovalsdeployPhases retentionPolicy,否则,你会得到错误。正文应如下所示:

{
"name": "New release pipeline russ",
"comment": "test",
"environments": [
{
"name": "PROD",
"preDeployApprovals": {
"approvals": [
{
"rank": 1,
"isAutomated": false,
"isNotificationOn": false,
"approver": {
"displayName": null,
"id": "aeb95c63-4fac-4948-84ce-711b0a9dda97"
},
"id": 0
}
]
},
"postDeployApprovals": {
"approvals": [
{
"rank": 1,
"isAutomated": true,
"isNotificationOn": false,
"id": 0
}
]
},
"deployPhases": [
{
"deploymentInput": {
"parallelExecution": {
"parallelExecutionType": "none"
},
"skipArtifactsDownload": false,
"artifactsDownloadInput": {},
"queueId": 391,
"demands": [],
"enableAccessToken": false,
"timeoutInMinutes": 0,
"jobCancelTimeoutInMinutes": 1,
"condition": "succeeded()",
"overrideInputs": {}
},
"rank": 1,
"phaseType": "agentBasedDeployment",
"name": "Run on agent",
"workflowTasks": []
}
],
"retentionPolicy": {
"daysToKeep": 30,
"releasesToKeep": 3,
"retainBuild": true
}
}
],
"path": "\\",
"releaseNameFormat": "Release",
"description": ""
}

关于azure - 创建 azure devops 发布管道时出错 - POST Rest api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62377937/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com