【问题标题】:Retrying a previously-run TFS build from powershell从 powershell 重试以前运行的 TFS 构建
【发布时间】:2016-04-19 04:56:51
【问题描述】:

我正在尝试以编程方式重试之前完成的 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

有什么想法我在这里做错了吗?或者可能知道重试先前构建的更好方法?

【问题讨论】:

  • 你有没有克服这个问题?我现在才遇到。太奇怪了,"can only be retried if the status is Completed. The status was Completed."

标签: powershell tfs build


【解决方案1】:

查看$qb.retry(); $qb.Save()发送的请求与右键重试Visual Studio的区别后,发现调用需要是:

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

retryOption 需要以Completed 显式传递,否则默认为InProgress

【讨论】:

    猜你喜欢
    • 2017-11-02
    • 2018-12-07
    • 2016-11-22
    • 2019-10-27
    • 1970-01-01
    • 2010-10-09
    • 2023-03-18
    • 1970-01-01
    • 2013-09-21
    相关资源
    最近更新 更多