VS402881:未指定与工件源' MyBuild相对应的工件版本。发布管理vNext REST API

时间:2016-04-14 22:58:44

标签: json rest tfs ms-release-management

我正在使用TFS 2015.2 RTM,我发现Release Management vNext REST API位于2.2-preview.1内部。我想创建一个版本,但我不知道要放在POST请求正文中的确切JSON,因为documentation仅适用于VSTS。

当我发送请求时,收到错误消息:

VS402881: No artifact version is specified corresponding to artifact source 'MyBuild.' Specify a valid value and try again. 

这是JSON:

$body = @"
     {
          definitionId": 1,
    "description": "test",
    "artifacts": [ 
      {
         "alias": "Tailspin Toys", 
         "version": {
               "id": 147,
         },
         "instanceReference": {
            "id": 5
        }
       }
     ]
} 
"@

这里是Invoke-RestMethod命令:

$releaseResponse = Invoke-RestMethod -Method Post -Credential $credential -ContentType application/json -Uri $postUri -Body $body

我错过了什么JSON项目?如果文档没有缺少的内容,如何找到JSON正文中的内容?

4 个答案:

答案 0 :(得分:2)

是的,当前版本的VSTS API与TFS 2015.2 API之间存在一些差异。但是大多数API应该可以工作,除了极少数。这是documentation link

以下是创建发布所需的JSON。 所需的JSON需要name instanceReference,尽管它是当前版本的VSTS API的可选项。

{
  "definitionId": 1,
  "description": "test",
  "artifacts": [
    {
      "alias": "Tailspin Toys",
      "instanceReference": {
        "id": "5",
        "name": "<build_name>"
      }
    }
  ]
}

答案 1 :(得分:0)

基于我的Fiddler捕获:

{
  "id": 0,
  "name": "xxx",
  "createdOn": "2016-04-15T06:48:14.173Z",
  "createdBy": null,
  "modifiedBy": null,
  "modifiedOn": null,
  "environments": [
    {
      "id": 0,
      "name": "Default Environment",
      "rank": 1,
      "deployStep": {
        "id": 0,
        "tasks": [ ]
      },
      "owner": {
        "displayName": "foobar",
        "id": "c236ac37-97ee-4ed0-b731-36ebb4a9ed3f",
        "isContainer": false,
        "uniqueName": "ad\foobar",
        "imageUrl": "http://tfs:8080/tfs/collection/_api/_common/IdentityImage?id=c236ac37-97ee-4ed0-b731-36ebb4a9ed3f&t=1460698957392&__v=5",
        "url": "http://tfs:8080/tfs/collection/"
      },
      "queueId": 1,
      "demands": [ ],
      "conditions": [ ],
      "variables": { },
      "runOptions": { "EnvironmentOwnerEmailNotificationType": "Always" },
      "executionPolicy": {
        "concurrencyCount": 0,
        "queueDepthCount": 0
      },
      "preDeployApprovals": {
        "approvals": [
          {
            "rank": 1,
            "isAutomated": true,
            "isNotificationOn": false,
            "id": 0
          }
        ],
        "approvalOptions": null
      },
      "postDeployApprovals": {
        "approvals": [
          {
            "rank": 1,
            "isAutomated": true,
            "isNotificationOn": false,
            "id": 0
          }
        ],
        "approvalOptions": null
      }
    }
  ],
  "artifacts": [ ],
  "variables": { },
  "triggers": [ ],
  "releaseNameFormat": "Release-$(rev:r)",
  "retentionPolicy": { "daysToKeep": 60 }
}

答案 2 :(得分:0)

对于类似错误 VS402962:未指定与工件来源“我的构建名称”相对应的工件版本ID。指定一个有效值,然后重试。

我按照this article的建议做了...

刷新页面,然后重试

答案 3 :(得分:-1)