【问题标题】:TFS shows success for a failed ANT buildTFS 显示失败的 ANT 构建成功
【发布时间】:2017-09-17 02:58:27
【问题描述】:

嗨,即使我的 ant 构建失败,TFS 也会显示该步骤成功并继续进行。我尝试过使用 failonerror,但似乎很少有任务可以使用 failonerror。是否有解决方法,以便在 ANT 构建失败时 TFS 实际上失败。

【问题讨论】:

    标签: tfs ant build failonerror


    【解决方案1】:

    您可以使用 logging commands 从您的 powershell 脚本返回警告和错误。先捕获ant build log,判断ant build是否失败。然后在 powershell 构建任务中使用task.logissue type=error,您可能会使构建任务失败,然后构建失败。

    更多细节你可以看看这个类似的问题:Is it possible to raise and display build warnings from build steps using TFS 2015

    【讨论】:

    • 您能详细说明一下吗?运行批处理脚本以发现构建失败后,如何使用 task.logissue 类型错误。我如何使构建任务和构建都失败?
    • @uttarabhosale 您可以在诸如Write-Host "##vso[task.logissue type=error;]Test error" 之类的 powershell 脚本中编写此代码,然后 powershell 任务将失败,整个构建将失败。更多详情请参考上述链接中mattbrooks2010的评论:github.com/Microsoft/vsts-tasks/issues/573
    • 您好 Patrick,我收到了问题下的错误日志。但是我的 powershell 脚本无法识别日志中的 Build Failed 字符串。这是我写的代码: $printCode =[int]$res.StatusCode Write-Host "Result Status Code:" $res.StatusCode "("$printCode")" If([int]$res.StatusCode - eq 0) {Write-Host "##vso[task.complete result=Succeeded;]Success"} 否则 {Write-Error "##vso[task.logissue type=error;]Test error"} 。日志中显示的状态码为 0,但 Build 为 Build Failed。可以请教吗?
    • 我想比较来自 vso 日志本身的字符串“Build Failed”,因为它将代码解析为 0,理想情况下应该是 1,因为构建失败。
    • @uttarabhosale 似乎成功构建的状态代码应该是 200...您可以通过成功构建来仔细检查这一点。看看这个问题。 stackoverflow.com/questions/34501891/…
    猜你喜欢
    • 1970-01-01
    • 2016-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多