2017-01-30 90 views
0

下顯示任務的父級PBI是否有任何方法在TFS2017下的列表中的發佈下顯示任務工作項目的父級PBI?TFS 2017發佈管理:如何在版本

下面的截圖顯示了與Release-3相關的兩項任務。在這裏,我希望能夠爲他們每個人顯示父PBI。無論是通過擴大他們或只是通過顯示鏈接附加列於母公司PBI enter image description here

我感謝你的幫助

編輯: 我知道這有可能創造TFS上查詢。問題是我需要顯示與特定版本相關的父工作項的信息,以便用戶可以使用它們進行報告。我試圖爲這個目的創建一個查詢,但我找不到基於Release的過濾選項,所以我認爲可以啓用一些額外的列或可能有一個擴展名,但我無法弄清楚如何做到這一點..

+0

似乎有ISN在這裏沒有顯示父級PBI的方法,但是您可以通過關聯的子工作項ID來查詢它們。 –

+0

是的,但用戶希望能夠根據所選版本查詢任務及其父級PBI以進行報告。你有一個想法如何做到這一點? 我已經在此發佈了另一個專門針對此處的文章: http://stackoverflow.com/questions/41934425/tfs-2017-release-management-how-to-display-parent-pbi-for-tasks-under-release – Sam00

+0

你可以嘗試通過擴展來實現。步驟:1.獲取指定版本(https://www.visualstudio.com/en-us/docs/integrate/api/rm/releases#get-a-release)以獲取構建ID 2.獲取構建的工作項每個版本ID(https://www.visualstudio.com/en-us/docs/integrate/api/build/builds#work-items)。關於如何構建擴展,可以參考https://www.visualstudio.com/en-us/docs/integrate/extensions/develop/add-dashboard-widget –

回答

1

的步驟來實現與延伸:

  1. 獲得指定的釋放得到建立ID
  2. 獲取每構建構建標識的工作項目
  3. 獲取相關的工作項目

有擴展的簡單的代碼來獲取特定版本的工作項目,你可以參考一下:

HTML:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Custom widget</title> 
    <meta charset="utf-8" /> 
    <script src="node_modules/vss-web-extension-sdk/lib/VSS.SDK.js"></script> 
    <script type="text/javascript"> 
     VSS.init({ 
      explicitNotifyLoaded: true, 
      usePlatformStyles:true 
     }); 
     VSS.require(["TFS/Dashboards/WidgetHelpers", "TFS/TestManagement/RestClient", "TFS/WorkItemTracking/RestClient", "TFS/Build/RestClient", "VSS/Service", "VSS/Identities/Contracts", "VSS/Identities/RestClient", "VSS/Authentication/Services"], function (WidgetHelpers, TFS_Test_WebApi, TFS_Work_WebApi, TFS_Build_Client, VSS_Service, idContracts, idRest, VSS_Auth_Service) { 
      WidgetHelpers.IncludeWidgetStyles(); 
      VSS.register("WidgetStarain", function() { 

       var authHeader = "none"; 
       var vstsAccount = "none"; 
       var projectName = "none"; 
       var releaseRestAPIPrex = "none" 
       var getReleaseWorkItems= function (widgetSettings) { 
        var c = VSS.getWebContext(); 
        vstsAccount = c.account.name; 
        projectName = c.project.name; 
        releaseRestAPIPrex="https://" + vstsAccount + ".vsrm.visualstudio.com/DefaultCollection/" + projectName + "/_apis/release" 
        VSS.getAccessToken().then(function (token) { 

         authHeader = VSS_Auth_Service.authTokenManager.getAuthorizationHeader(token); 

         $.ajax({ 
          type: 'GET', 
          url: releaseRestAPIPrex+'/definitions?api-version=3.0-preview.1', 
          cache: false, 
          dataType: 'json', 
          beforeSend: function (xhr) { 
           xhr.setRequestHeader("Authorization", authHeader); 
          }, 
         }).done(function (data) { 
          var v = data.value; 
          $("#releaseDefList").empty(); 
          $("#releaseDefList").append('<option value="select">select</option>'); 
          $.each(v, function (index, value) { 
           $("#releaseDefList").append('<option value="' + value.id + '">' + value.name + '</option>'); 
          }); 
         }).error(function (e) { 
          var s = "ss"; 
         }); 

        }); 

       }; 
       $("#releaseDefList").change(function() { 
        var str = ""; 
        $("#releaseList").empty(); 
        $("#releaseList").append('<option value="select">select</option>'); 
        $("#releaseDefList option:selected").each(function() { 

         var releaseDefId = $(this).val(); 
         if (releaseDefId != "select") { 
          $.ajax({ 
           type: 'GET', 
           url: releaseRestAPIPrex+'/releases?definitionId=' + releaseDefId + '&api-version=3.0-preview.2', 
           cache: false, 
           dataType: 'json', 
           beforeSend: function (xhr) { 
            xhr.setRequestHeader("Authorization", authHeader); 
           }, 
          }).done(function (data) { 
           var v = data.value; 

           $.each(v, function (index, value) { 
            $("#releaseList").append('<option value="' + value.id + '">' + value.name + '</option>'); 
           }); 
          }).error(function (e) { 
           var s = "ss"; 
          }); 
         } 

        }); 


       }); 
       $("#releaseList").change(function() { 
        var str = ""; 

        $("#releaseList option:selected").each(function() { 

         var releaseId = $(this).val(); 
         if (releaseId != "select") { 
          $.ajax({ 
           type: 'GET', 
           url: releaseRestAPIPrex+'/release/releases/' + releaseId + '?api-version=3.0-preview.2',         
           cache: false, 
           dataType: 'json', 
           beforeSend: function (xhr) { 
            xhr.setRequestHeader("Authorization", authHeader); 
           }, 
          }).done(function (data) { 
           var artifacts = data.artifacts; 
           $.each(artifacts, function (index, value) { 
            var buildId = value.definitionReference.version.id; 

            TFS_Build_Client.getClient().getBuildWorkItemsRefs(projectName, buildId).then(function (workitemRefs) { 
             var workItemIds = new Array(); 
             $.each(workitemRefs, function (index, value) { 
              workItemIds.push(value.id); 
             }); 
             var workitemString = ""; 
             TFS_Work_WebApi.getClient().getWorkItems(workItemIds,null,null,"All").then(function (workitems) { 
              $.each(workitems, function (index, value) { 
               workitemString += "ID: " + value.id + "; Title: " + value.fields["System.Title"]; 
              }); 
              $("#workitems").text(workitemString); 
             }); 

            }); 
           }); 

          }).error(function (e) { 
           var s = "ss"; 
          }); 
         } 

        }); 


       }); 
       return { 
        load: function (widgetSettings) { 
         getReleaseWorkItems(widgetSettings); 
         return WidgetHelpers.WidgetStatusHelper.Success(); 
        } 
       } 
      }); 
      VSS.notifyLoadSucceeded(); 
     }); 
    </script> 
</head> 
<body> 
    <div class="widget"> 
     <h2 class="title">widgets starain</h2> 
     <div class="token">none</div> 

     <select id="releaseDefList"> 
      <option id="select">select</option> 
     </select> 
     <select id="releaseList"> 
      <option id="select">select</option> 
     </select> 
     <div id="workitems"> 
      none workitem 
     </div> 


    </div> 
</body> 
</html> 

VSS-extension.json:

{ 
    "manifestVersion": 1, 
    "id": "sample-extension", 
    "version": "0.5.34", 
    "name": "My test extension", 
    "description": "my test extension description", 
    "publisher": "Starain", 
    "targets": [ 
    { 
     "id": "Microsoft.VisualStudio.Services" 
    } 
    ], 
    "icons": { 
    "default": "Images/logo.png" 
    }, 
    "scopes": [ 
    "vso.work", 
    "vso.build", 
    "vso.build_execute", 
    "vso.test", 
    "vso.test_write", 
    "vso.release" 
    ], 
    "contributions": [ 
     { 
     "id": "WidgetStarain", 
     "type": "ms.vss-dashboards-web.widget", 
     "targets": [ "ms.vss-dashboards-web.widget-catalog", "Starain.sample-extension.WidgetStarainConfiguration" ], 
     "properties": { 
     "name": "widget starain", 
     "description": "custom widget", 
     "catelogIconUrl": "Images/iconProperty.png", 
     "previewImageUrl": "Images/iconProperty.png", 
     "uri": "WidgetStarain.html", 
     "supportedSizes": [ 
      { 
      "rowSpan": 1, 
      "columnSpan": 2 
      } 
     ], 
     "supportedScopes": [ "project_team" ] 
     } 
    } 
    ], 
    "files": [ 
    { 
     "path": "node_modules/vss-web-extension-sdk/lib", 
     "addressable": true 
    }, 
    { 
     "path": "Images", 
     "addressable": true 
    }, 
    { 
     "path": "Scripts", 
     "addressable": true 
    }, 
    { 
     "path": "WidgetStarain.html", 
     "addressable": true 

    } 
    ] 
} 
+0

嗨,這段代碼仍然有效嗎?我可以得到發佈定義和後續版本的列表,但是當選擇我知道的具有與其鏈接的工作項目的特定版本時,我只會看到:「沒有任何工作項目」。我不確定構建/工作項API是否仍然有效。感謝您的幫助 – Soccerjoshj07

+0

想通了:)。 「url:releaseRestAPIPrex +'/ release/releases /'」應該是 「url:releaseRestAPIPrex +'/ releases /'」;我們已經在前綴中包含URL的「/ release」部分。 – Soccerjoshj07