2016-04-27 81 views
0

我在Visual Studio Team Services中有幾個項目:一個用於服務器端代碼,另一個用於富含JavaScript的UI。我現在試圖爲團隊設置一個儀表板,以查看構建狀態和測試覆蓋率等事情,並且無法弄清楚如何從Visual Studio Team Services中獲取數據,或者如果可能的話。如何從Visual Studio團隊服務導出測試結果

我已經嘗試爲項目創建一個服務鉤子,並附加一個新的WebHook訂閱者。然後將一個JSON對象發佈到我的儀表板中,其中包含它允許我發送的所有信息。建立網絡掛接時,這是從「測試」按鈕的例子:

{ 
    "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&amp;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&amp;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" 
} 

這裏有一些有用的領域在resource財產,如statusstartTimefinishTime(從中我可以計算出如何花了很長時間)。但是這些測試沒有任何關係。

在我的UI項目中,測試和覆蓋都有一個發佈步驟,將結果保存到構建服務器上的XML文件。因此,我現在唯一能看到與儀表板共享更多詳細信息的方法是編寫一個自定義腳本,將這些XML文件讀取並作爲構建的最後一步發佈到REST API。

如果有人知道一種更簡潔的方式讓VSTS去做我需要的東西,那麼我就會全神貫注。

回答

0

你想要的信息存儲在「TestRuns」中。當您爲「構建完成」事件創建服務掛鉤時,它僅發送包含在構建中的信息。所以沒有包含測試信息。但是,您可以編寫一個腳本,通過VSTS Rest Api在Service Hooks中的「builduri」信息中獲取相關的測試運行信息。 enter image description here

相關問題