我在Visual Studio Team Services中有几个项目:一个用于服务器端代码,另一个用于富含javascript的UI。我现在正在尝试为团队设置仪表板,以查看构建状态和测试覆盖率等内容,并且无法弄清楚如何从Visual Studio Team Services中获取数据,或者是否有这样的事情是可能的。
我尝试为项目创建Service Hook,并附加一个新的WebHook订阅者。然后,这会将JSON对象发布到我的仪表板,其中包含允许我发送的所有信息。以下是"测试"的示例。设置WebHook时按钮:
{
"subscriptionId": "2d0988c2-e1a6-45b7-ada0-cf3355beeb9f",
"notificationId": 4,
"id": "4a5d99d6-1c75-4e53-91b9-ee80057d4ce3",
"eventType": "build.complete",
"publisherId": "tfs",
"message": {
"text": "Build ConsumerAddressModule_20150407.2 succeeded",
"html": "Build <a href=\"https://fabrikam-fiber-inc.visualstudio.com/web/build.aspx?pcguid=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3\">ConsumerAddressModule_20150407.2</a> succeeded",
"markdown": "Build [ConsumerAddressModule_20150407.2](https://fabrikam-fiber-inc.visualstudio.com/web/build.aspx?pcguid=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3) succeeded"
},
"detailedMessage": {
"text": "Build ConsumerAddressModule_20150407.2 succeeded",
"html": "Build <a href=\"https://fabrikam-fiber-inc.visualstudio.com/web/build.aspx?pcguid=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3\">ConsumerAddressModule_20150407.2</a> succeeded",
"markdown": "Build [ConsumerAddressModule_20150407.2](https://fabrikam-fiber-inc.visualstudio.com/web/build.aspx?pcguid=5023c10b-bef3-41c3-bf53-686c4e34ee9e&builduri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f3) succeeded"
},
"resource": {
"uri": "vstfs:///Build/Build/2",
"id": 2,
"buildNumber": "ConsumerAddressModule_20150407.1",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Builds/2",
"startTime": "2015-04-07T18:04:06.83Z",
"finishTime": "2015-04-07T18:06:10.69Z",
"reason": "manual",
"status": "succeeded",
"dropLocation": "#/3/drop",
"drop": {
"location": "#/3/drop",
"type": "container",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/resources/Containers/3/drop",
"downloadUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/resources/Containers/3/drop?api-version=1.0&$format=zip&downloadFileName=ConsumerAddressModule_20150407.1_drop"
},
"log": {
"type": "container",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/resources/Containers/3/logs",
"downloadUrl": "https://fabrikam-fiber-inc.visualstudio.com/_apis/resources/Containers/3/logs?api-version=1.0&$format=zip&downloadFileName=ConsumerAddressModule_20150407.1_logs"
},
"sourceGetVersion": "LG:refs/heads/master:600c52d2d5b655caa111abfd863e5a9bd304bb0e",
"lastChangedBy": {
"id": "d6245f20-2af8-44f4-9451-8107cb2767db",
"displayName": "Normal Paulk",
"uniqueName": "fabrikamfiber16@hotmail.com",
"url": "https://fabrikam-fiber-inc.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
},
"retainIndefinitely": false,
"hasDiagnostics": true,
"definition": {
"batchSize": 1,
"triggerType": "none",
"definitionType": "xaml",
"id": 2,
"name": "ConsumerAddressModule",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Definitions/2"
},
"queue": {
"queueType": "buildController",
"id": 4,
"name": "Hosted Build Controller",
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/build/Queues/4"
},
"requests": [{
"id": 1,
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Requests/1",
"requestedFor": {
"id": "d6245f20-2af8-44f4-9451-8107cb2767db",
"displayName": "Normal Paulk",
"uniqueName": "fabrikamfiber16@hotmail.com",
"url": "https://fabrikam-fiber-inc.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
}
}]
},
"resourceVersion": "1.0",
"resourceContainers": {
"collection": {
"id": "c12d0eb8-e382-443b-9f9c-c52cba5014c2"
},
"account": {
"id": "f844ec47-a9db-4511-8281-8b63f4eaf94e"
},
"project": {
"id": "be9b3917-87e6-42a4-a549-2bc06a7a878f"
}
},
"createdDate": "2016-04-27T14:45:20.8150184Z"
}
resource
属性中有一些有用的字段,例如status
,startTime
和finishTime
(我可以从中了解构建所花费的时间)。但是没有关于测试的内容。
在我的UI项目中,测试和覆盖都有一个发布步骤,可以将结果保存到构建服务器上的XML文件中。因此,我可以看到与仪表板分享更多详细信息的唯一方法是编写一个自定义脚本来读取这些XML文件,并将它们作为构建的最后一步发布到REST API。
如果有人知道更清洁的方式让VSTS做我需要的事情,那么我全都听见了。
答案 0 :(得分:0)
您想要的信息存储在&#34; TestRuns&#34;中。为&#34; Build Completed&#34;创建服务挂钩时事件,它只发送构建中包含的信息。所以没有包含测试信息。但是,您可以使用&#34; builduri&#34;编写脚本来获取相关的测试运行信息。服务挂钩中的信息通过VSTS Rest Api。