2016-09-16 12 views
0

VSTS拡張でカスタムビルドタスクからVSTS作業項目を作成する必要があります。これはMicrosoftによって提供されるAPIラッパーですか?これに最善のアプローチは何でしょうか?カスタムビルドタスクからVSTSワークアイテムを作成する方法は?

ありがとうございます。

+0

TFS REST APIを使用しようとしましたか? https://www.visualstudio.com/docs/integrate/api/wit/work-items#create-a-work-item – ds19

答えて

1

を参照することができますあなたのtypescriptですでVSTS Node APIを使用することができますあなたが望む機能を実現します。必要な方法は​​です。

+0

@BandRこれは機能しますか? –

0

今のところ、このビルドイン機能やビルドタスクはTFSにありません。

しかし、ds19と同じようにTFS REST APIを使用すると、powershellスクリプトが示唆するようになります。所有者拡張を作成する必要はありません。

のREST API:以下Create a work item

PATCH https://{instance}/DefaultCollection/{project}/_apis/wit/workitems/${workItemTypeName}?api-version={version} 

はサンプルコードです:

Try 

{ 



$WorkItemAssociatedURL = $collectionURL + $project + “/_apis/build/builds/” + $BuildId + “/workitems?api-version=2.0” 

$ResponseJSON = Invoke-RestMethod -Uri $WorkItemAssociatedURL -ContentType “application/json” -headers $headers -Method GET 



$CountWorkitems = $ResponseJSON.count 

$WorkitemUrlArray = $ResponseJSON.value 



for($i = 0; $i -lt $CountWorkitems ; $i++) 

{ 

$body = 

‘[ 

{ 

“op”: “add”, 

“path”: “/fields/Microsoft.VSTS.Build.IntegrationBuild”, 

“value”:’ + $BuildNumber +’ 

} 

]’ 



$WorkitemUpdateURL = $WorkitemUrlArray[$i].url + “?api-version=1.0” 



Invoke-RestMethod -Uri $WorkitemUpdateURL -Body $body -ContentType “application/json-patch+json” -headers $headers -Method Patch 

} 

} 



Catch 

{ 

Write-Host “No work item associated with this build. Kindly check the changesets” 

} 

より詳細な手順と情報あなたはこのブログにBuild association with work Items in vNext

+0

返信いただきありがとうございますPatrick、私の拡張機能はすでにtypescriptを使用して開発されています。いくつかのデータを取得するために外部サービスを使用し、受信したデータの作業項目を作成する必要があります。私は次の例を見つけましたが、クライアント側で動作するVSS SDKを使用しています。 [例](https://nocture.dk/2016/01/02/lets-make-a-visual-studio-team-services-extension/) – Bandara

関連する問題