簡體   English   中英

從Powershell重試先前運行的TFS構建

[英]Retrying a previously-run TFS build from powershell

我正在嘗試以編程方式重試以前完成的TFS構建。 (就像您可以通過“操作,重試構建”在VS中進行操作一樣。)

我下面的示例PS代碼連接到TSF,通過其ID捕獲先前構建的構建隊列,並嘗試設置其重試狀態並保存。 保存失敗,表示構建狀態需要為“已完成”。 查詢狀態顯示“已完成”。

. ".\loadTfsAssemlies.ps1"

$tfsURL = "http://myServer:8080/tfs/myCollection"
$tpc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsURL)
$bs = $tpc.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
$qb = $bs.getqueuedbuild(258498,"All")

$qb.retry()
$qb.save()

Exception calling "Save" with "0" argument(s): "Queued build 258498 on build controller blah blah can only be retried if the status is Completed. The status was Completed."
At line:1 char:1
+ $qb.save()
+ ~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : QueuedBuildUpdateException

 $qb.status
Completed

有什么想法我在這里做錯了嗎? 還是知道重試以前的構建的更好方法?

在檢查了$qb.retry(); $qb.Save()發送的請求之間的差異之后$qb.retry(); $qb.Save() $qb.retry(); $qb.Save()並右鍵單擊重試Visual Studio,我發現調用需要為:

qb.Retry([Guid]::NewGuid(), "Completed")
qb.Save()

retryOption需要顯式傳遞為Completed ,否則默認為InProgress

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM