我們有一個自定義構建過程(不使用MS構建),並且在此過程中,我將一個「假」構建添加到全局構建列表。我這樣做的原因是,您可以選擇給定工作項目的構建(在構建中找到)。我們有一個自定義字段,包含構建,用於顯示該工作項固定在哪個構建中。我無法確定如何以編程方式更新此字段。這個想法是,我將有一個小應用程序,它會在構建過程中調用這些應用程序,查找自上次構建以來的所有工作項目,然後更新這些工作項目的字段。有任何想法嗎?如何以編程方式更新自定義TFS字段
5
A
回答
13
像這樣的東西應該爲你工作:
public void UpdateTFSValue(string tfsServerUrl, string fieldToUpdate,
string valueToUpdateTo, int workItemID)
{
// Connect to the TFS Server
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsUri));
// Connect to the store of work items.
_store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
// Grab the work item we want to update
WorkItem workItem = _store.GetWorkItem(workItemId);
// Open it up for editing. (Sometimes PartialOpen() works too and takes less time.)
workItem.Open();
// Update the field.
workItem.Fields[fieldToUpdate] = valueToUpdateTo;
// Save your changes. If there is a constraint on the field and your value does not
// meet it then this save will fail. (Throw an exception.) I leave that to you to
// deal with as you see fit.
workItem.Save();
}
調用此的一個例子是:
UpdateTFSValue("http://tfs2010dev:8080/tfs", "Integration Build", "Build Name", 1234);
變量fieldToUpdate
應該是實地,而不是refname的名稱(即Integration Build,而不是Microsoft.VSTS.Build.IntegrationBuild)
你可能會使用PartialOpen(),但我不確定。
您可能需要將Microsoft.TeamFoundation.Client
添加到您的項目中。 (也許Microsoft.TeamFoundation.Common
)
4
這種情況已經改變了2012 TFS,basicly必須添加workItem.Fields [fieldToUpdate] .value的
更新的版本是什麼@Vaccano寫道。
public void UpdateTFSValue(string tfsServerUrl, string fieldToUpdate,
string valueToUpdateTo, int workItemID)
{
// Connect to the TFS Server
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsUri));
// Connect to the store of work items.
_store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
// Grab the work item we want to update
WorkItem workItem = _store.GetWorkItem(workItemId);
// Open it up for editing. (Sometimes PartialOpen() works too and takes less time.)
workItem.Open();
// Update the field.
workItem.Fields[fieldToUpdate].Value = valueToUpdateTo;
// Save your changes. If there is a constraint on the field and your value does not
// meet it then this save will fail. (Throw an exception.) I leave that to you to
// deal with as you see fit.
workItem.Save();
}
相關問題
- 1. TFS 2012拉取自定義映射字段編程方式
- 2. TFS 2017更新1:以編程方式更新TFS發佈定義刪除服務器階段(手動干預)
- 3. 如何以編程方式更新餘燼輸入字段
- 4. wordpress圖像以編程方式上傳到自定義字段
- 5. 如何以編程方式更改自定義組件高度
- 6. RxSwift - UITextField以編程方式更新時未更新UILabel字段
- 7. 以編程方式自定義樣式
- 8. 高級自定義字段 - 以編程方式插入帖子並更新中繼器字段
- 9. 在wordpress後端以編程方式輸出「高級自定義字段」字段
- 10. 如何以編程方式爲Project Server創建企業自定義字段
- 11. 如何以編程方式渲染drupal 7 page.tpl.php中的自定義字段?
- 12. 如何以編程方式更新與Google Analytics中的客戶端ID關聯的自定義字段?
- 13. 如何以編程方式在TFS中獲取新創建的定義?
- 14. 如何以編程方式確定是否需要TFS WorkItem字段?
- 15. 如何在magento中以編程方式更新自定義選項?
- 16. 以編程方式更新UWP綁定
- 17. 如何以編程方式註冊自定義URL方案?
- 18. 如何以編程方式更改預定義的Drools流程?
- 19. 以編程方式更新Drupal CCK字段
- 20. 以編程方式更新SharePoint中的多個字段
- 21. 以編程方式更新tfs工作區中的文件
- 22. 如何以編程方式創建新的TFS任務?
- 23. 如何以編程方式合併TFS更改集?
- 24. 以編程方式獲取TFS構建定義元數據
- 25. 我如何添加到AllowableValues列表自定義字段在TFS 2010編程
- 26. 如何以編程方式訪問頁面片段自定義屬性?
- 27. 以編程方式更改自定義ListView的顏色?
- 28. 以編程方式寫入自定義表並記錄更改
- 29. 以編程方式更改自定義操作欄的標題
- 30. 以編程方式更改自定義Android鍵盤的鍵盤
您可以更具體地瞭解全局構建列表部分。您是否使用自定義構建模板(在Windows Workflow Foundation中)?你是否添加到該模板中的變量或參數? – LWoodyiii 2011-02-07 18:21:37
對不起,我正在使用TFS中的全局列表。我沒有使用構建模板,我們正在使用名爲Automated Build Studio的產品作爲實際構建本身。我正打算編寫一個獨立的應用程序來從ABS呼叫此功能。 – Nick 2011-02-07 18:37:24