[英]Error while creating azure devops release pipeline - POST rest api
Facing an issue while creating a ADO release pipeline - with powershell ADO rest API.在创建 ADO 发布管道时遇到问题 - 使用 powershell ADO rest API。
Below is the code -下面是代码 -
[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)}
And the error that I got is --我得到的错误是——
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
Found similar issue in VS developer community blog, unfortunately no help in it -在 VS 开发者社区博客中发现了类似的问题,不幸的是没有帮助 -
https://developercommunity.visualstudio.com/content/problem/582209/post-example-to-create-a-release-pipeline.html https://developercommunity.visualstudio.com/content/problem/582209/post-example-to-create-a-release-pipeline.html
Any inputs are much appreciate.任何投入都非常感谢。
Thanks,谢谢,
The environments
in the body should include at least name
, preDeployApprovals
, postDeployApprovals
, deployPhases
, retentionPolicy
, otherwise, you'll get error.正文中的
environments
至少应包括name
、 preDeployApprovals
、 postDeployApprovals
、 deployPhases
、 retentionPolicy
,否则会出错。 The body should look like below:身体应该如下所示:
{
"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": ""
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.