グローバルリストを更新するためのRest APIがないため、VSTS/TFSクライアントAPI(WorkItemStore.ImportGlobalListsメソッド)またはwitadmin commandsを使用してグローバルリストを更新できます。
PowerShellを使用したサンプル:Get TfsCollection and TFS ServicesおよびAdding to a GlobalList。
function Add-TfsGlobalListItem {
Param(
[parameter(Mandatory=$true)][Microsoft.TeamFoundation.Client.TfsTeamProjectCollection] $TfsCollection,
[parameter(Mandatory=$true)][String] $GlobalListName,
[parameter(Mandatory=$true)][String] $GlobalEntryValue
)
# Get Global List
$store = Get-TfsWorkItemStore $TfsCollection
[xml]$export = $store.ExportGlobalLists();
$globalLists = $export.ChildNodes[0];
$globalList = $globalLists.SelectSingleNode("//GLOBALLIST[@name='$GlobalListName']")
# if no GL then add it
If ($globalList -eq $null)
{
$globalList = $export.CreateElement("GLOBALLIST");
$globalListNameAttribute = $export.CreateAttribute("name");
$globalListNameAttribute.Value = $GlobalListName
$globalList.Attributes.Append($globalListNameAttribute);
$globalLists.AppendChild($globalList);
}
#Create a new node.
$GlobalEntry = $export.CreateElement("LISTITEM");
$GlobalEntryAttribute = $export.CreateAttribute("value");
$GlobalEntryAttribute.Value = $GlobalEntryValue
$GlobalEntry.Attributes.Append($GlobalEntryAttribute);
#Add new entry to list
$globalList.AppendChild($GlobalEntry)
# Import list to server
$store.ImportGlobalLists($globalLists)
一方、ビルドの関連作業項目を更新するには、この記事を参照することができますBuild association with work Items in vNext
アップデート:VSTSに接続する
シンプルコード:
param(
[string]$address,
[string]$username,
[string]$password
)
$credentials = New-Object System.Net.NetworkCredential($username, $password)
$tfsCollection = New-Object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection((New-Object System.URI($address)))
$wis = $tfsCollection.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
次に、PowerShellタスク(ビルドまたはリリース)の引数テキストボックス-address XXX -username XXX -password XXX
で引数を指定できます。 (ユーザー名は空で、パスワードとして個人用のアクセストークンを使用できます)
一方、Microsoft Team Foundation Server Extended Client packageにあるアセンブリファイルをインポートすることができます。
ソリューションを共有していただきありがとうございます。パワーシェルで$ TfsCollection URIの資格情報を渡すには? –
@DeepakGargこの記事のもう1つの部分はhttps://nkdagility.com/powershell-tfs-2013-api-1-get-tfscollection-and-tfs-services/です。また、簡単なコードで自分の答えを更新しましたVSTS。注:ビルドまたはリリース中に行う場合は、ユーザー名とパスワードを指定する必要があります。 –