2017-06-11 65 views
0

我監視建立在TFS & VSTS,並想知道如何讓一個正在運行的構建或發佈的整體進度(百分比)。如何使用TFS REST API獲取正在運行的構建的進度?

+1

什麼版本的TFS?你在使用XAML構建? – JamesQMurphy

+0

使用招或瀏覽器控制檯,並嗅出正在運行的REST調用建立 – k7s5a

+0

什麼下列要求的回報? 「GET https:// {instance}/DefaultCollection/{project}/_apis/build/builds/{buildId}?api-version = {version}」 – Eduard

回答

1

您可以使用REST API Get build details與時間表。

GET https://{instance}/DefaultCollection/{project}/_apis/build/builds/{buildId}/timeline?api-version={version} 

將返回構建時間表和包括PERCENTCOMPLETE結果一些更詳細的信息。注意:這是基於webportal中構建日誌的任務級別,而不是整個構建。

樣本響應

{ 
    "records": [ 
    { 
     "id": "bcddc27d-c891-4209-85d6-387e155439b0", 
     "parentId": "045f4ce9-cb71-424f-84de-4ab19281dc70", 
     "type": "Task", 
     "name": "Build solution **\\*.sln", 
     "startTime": "2015-07-16T19:53:20.853Z", 
     "finishTime": "2015-07-16T19:53:28.567Z", 
     "currentOperation": null, 
     "percentComplete": 100, 
     "state": "completed", 
     "result": "succeeded", 
     "resultCode": null, 
     "changeId": 16, 
     "lastModified": "0001-01-01T00:00:00", 
     "workerName": "Hosted Agent", 
     "order": 2, 
     "details": { 
     "id": "ef959107-e566-4c28-8d9f-354d605dd400", 
     "changeId": 6, 
     "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/build/builds/391/Timeline/ef959107-e566-4c28-8d9f-354d605dd400" 
     }, 
     "errorCount": 0, 
     "warningCount": 1, 
     "url": null, 
     "log": { 
     "id": 2, 
     "type": "Container", 
     "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/build/builds/391/logs/2" 
     }, 
     "issues": [ 
     { 
      "type": "warning", 
      "category": "General", 
      "message": "The MSBuild version parameter has been deprecated. Ignoring value: latest", 
      "data": { 
      "type": "warning" 
      } 
     } 
     ] 
    }, 
    { 
     "id": "b5bb4de7-a8ea-4c7d-8491-3f745bba7d1b", 
     "parentId": "045f4ce9-cb71-424f-84de-4ab19281dc70", 
     "type": "Task", 
     "name": "Get sources", 
     "startTime": "2015-07-16T19:53:07.057Z", 
     "finishTime": "2015-07-16T19:53:19.493Z", 
     "currentOperation": null, 
     "percentComplete": 100, 
     "state": "completed", 
     "result": "succeeded", 
     "resultCode": null, 
     "changeId": 13, 
     "lastModified": "0001-01-01T00:00:00", 
     "workerName": "Hosted Agent", 
     "order": 1, 
     "details": null, 
     "errorCount": 0, 
     "warningCount": 0, 
     "url": null, 
     "log": { 
     "id": 1, 
     "type": "Container", 
     "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/build/builds/391/logs/1" 
     } 
    }, 

enter image description here

+0

我正在尋找一種解決方案來獲取或計算整體進度的估算,而不僅僅是構建中的單個任務。 –

+0

@AlonAmsalem不幸的是,現在還不能使用Rest API。你可以在https://visualstudio.uservoice.com/forums/330519-team-services這個鏈接中添加一個uservoice,TFS PM會很好的回顧你的建議。 –

相關問題