通过 Rest 创建没有工件的 Azure DevOps 版本 API

Create Azure DevOps release without artifacts via Rest API

我正在根据 documentation 构建一个 JSON 主体。它看起来像这样(从文档中复制):

{
  "definitionId": 1,
  "description": "Creating Sample release",
  "artifacts": [
    {
      "alias": "Fabrikam.CI",
      "instanceReference": {
        "id": "2",
        "name": null
      }
    }
  ],
  "isDraft": false,
  "reason": "none",
  "manualEnvironments": null
}

但是,此版本没有任何工件。这只是需要 运行 的阶段。我尝试将 "artifacts" 值设置为 null 和 false。我还尝试完全删除 "artifacts" 键,如下所示:

{
  "definitionId": 1,
  "description": "Creating Sample release",
  "isDraft": false,
  "reason": "none",
  "manualEnvironments": null
}

不幸的是,所有这些猜测只会引发以下错误之一:

The artifact alias cannot be empty. Specify a valid artifact alias and try again.

Release pipeline name cannot be empty. Specify a name and try again.

如何使用 REST 创建不包含工件的版本 API?

How do I create a release that doesn't include artifacts using the REST API?

只需将其留空即可。使用这样的格式:

{
  "definitionId": 1,
  "description": "Creating Sample release",
  "artifacts": [],
  "isDraft": false,
  "reason": "none",
  "manualEnvironments": null
}

如果响应为 200 OK,则表示您 运行 其余 api 成功。 (这个api是用来创建release而不是创建release pipeline的,你应该知道!)