I have a couple of projects in Visual Studio Team Services: one for server side code, and another for the javascript-rich UI. I'm now trying to set up a dashboard for the team to see things like build status and test coverage, and can't figure out how to get the data out of Visual Studio Team Services, or if such a thing is possible.
I've tried creating a Service Hook for the project, and attaching a new WebHook subscriber. This then posts a JSON object to my dashboard containing all information that it will let me send. Here is an example from the "test" button when setting up the 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": "[email protected]",
"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": "[email protected]",
"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"
}
There are a few useful fields here in the resource property, such as status, startTime and finishTime (from which I can work out how long the build took). But there is nothing about the tests.
In my UI project, the tests and coverage both have a publish step that saves the results to an XML file on the build server. So at the minute the only way I can see to share more detailed information with the dashboard is to write a custom script that reads those XML files and POSTs them to a REST API as the final step of the build.
If anyone knows of a cleaner way to get VSTS to do what I need, I'm all ears.
