简体   繁体   English

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

[英]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至少应包括namepreDeployApprovalspostDeployApprovalsdeployPhasesretentionPolicy ,否则会出错。 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.

相关问题 使用 Rest API 在 Azure Devops 中创建工作项时出错 - Error while creating Work Item in Azure Devops using Rest API 如何使用 Azure DevOps REST API 运行构建/发布管道 - How to run build/release pipeline using Azure DevOps REST API 如何在通过 REST API for Z3A580F1420203677F1ZFZFZ3A580F1420203677F1ZBBCF 服务创建错误时找到发布说明字段的 API 端点 - How to find API end point for Release Notes field while creating bug via REST API for Azure DevOps Services Azure DevOps 管道发布 - 错误:getaddrinfo ENOTFOUND - Azure DevOps Pipeline Release - Error: getaddrinfo ENOTFOUND Azure DevOps 发布管道 - Azure Devops Release Pipeline 获取“远程服务器返回错误:(401) 未经授权。” 在 Azure DevOps 管道中创建发布时 - Getting "The remote server returned an error: (401) Unauthorized." when creating a release in Azure DevOps pipeline Azure DevOps REST API:创建版本时构建 ID/编号无效 - Azure DevOps REST API: invalid build id/number when creating a release Azure Devops-发布流水线 - Azure Devops-release pipeline 如何在 azure devops 扩展 api 中获取当前版本的管道 ID - How to get the pipeline Id of the current release in azure devops extension api Azure Devops 发布管道导致服务连接错误 - Azure Devops Release pipeline causing Service Connection Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM