VS402881: No artifact version is specified corresponding to artifact source 'MyBuild.' Release Management vNext REST API

只愿长相守 提交于 2019-12-31 00:52:07

问题


I'm using TFS 2015.2 RTM and I just found out that the Release Management vNext REST API is in 2.2-preview.1 on-premises. I want to create a release, but I don't know the exact JSON to put in the body of the POST request since the documentation only works for VSTS.

When I send the request, I get the error message:

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

Here's the JSON:

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

And here's the Invoke-RestMethod command:

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

What JSON items am I missing? How do I find what to put in the JSON body if the docs don't have what is missing?


回答1:


Yes there are some disparities between the current version of VSTS APIs and the TFS 2015.2 APIs. But most of the APIs should work except a very few. Here is the documentation link.

Following is the required JSON for creating a release. The required JSON needs to have the name in instanceReference although its optional for the current version of VSTS API.

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



回答2:


Based on my Fiddler capture:

{
  "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 }
}



回答3:


You may take a look into the sample usage http://blogs.msdn.com/b/chandananjani/archive/2016/04/15/using-releasemanagement-rest-api-s.aspx



来源:https://stackoverflow.com/questions/36635473/vs402881-no-artifact-version-is-specified-corresponding-to-artifact-source-myb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!