TFS 为运行任务构建自定义条件 - 检查特定的先前任务是否失败 [英] TFS build custom conditions for running a task - check if specific previous task has failed

查看:25
本文介绍了TFS 为运行任务构建自定义条件 - 检查特定的先前任务是否失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TFS 构建允许指定运行任务的条件:参考.

TFS build allows to specify conditions for running a task: reference.

我想定义的条件是:一个特定的任务[按名称或其他方式处理]失败了.

The condition I would like to define is: a specific task [addressed by name or other mean] has failed.

这类似于Only when a previous task has failed,但我想指定是哪个以前的任务.

This is similar to Only when a previous task has failed, but I want to specify which previous task that is.

查看示例,我没有看到任何解决特定任务结果的条件,只有整个构建状态.

Looking at the examples I don't see any condition that is addressing a specific task outcome, only the entire build status.

有可能吗?有什么解决方法可以实现这一目标吗?

Is it possible? any workaround to achieve this?

推荐答案

似乎没有针对此要求的现成解决方案,但我可以想出(一个丑陋的 :))解决方法.

It doesn't seem like there's an out-of-the-box solution for this requirement, but I can come up with (an ugly :)) workaround.

假设您的特定任务(您检查其状态的任务)称为 A.目标是仅在 A 失败的情况下调用另一个构建任务(比方说 B).

Suppose your specific task (the one you examine in regards to its status) is called A. The goal is to call another build task (let's say B) only in case A fails.

您可以执行以下操作:

  • 定义一个 自定义构建变量,将其命名为 task.A.status 并设置为 success
  • 创建另一个构建任务,例如C 并在 A 之后安排它;将它设置为仅在 A 失败时运行 - 有一个标准条件
  • 任务 C 应该只做一件事 - 将 task.A.status 构建变量设置为失败"(就像这样,如果我们正在谈论 PowerShell:Write-Host "##vso[task.setvariable variable=task.A.status]failure")
  • 最后,任务 B 被安排在 C有条件运行,以防task.A.status等于 failure,像这样:eq(variables['task.A.status'], 'failure')
  • Define a custom build variable, call it task.A.status and set to success
  • Create another build task, e.g. C and schedule it right after A; condition it to only run if A fails - there's a standard condition for that
  • The task C should only do one thing - set task.A.status build variable to 'failure' (like this, if we are talking PowerShell: Write-Host "##vso[task.setvariable variable=task.A.status]failure")
  • Finally, the task B is scheduled sometime after C and is conditioned to run in case task.A.status equals failure, like this: eq(variables['task.A.status'], 'failure')

我的语法细节可能不正确,但您应该大致了解.希望有帮助.

I might be incorrect in syntax details, but you should get the general idea. Hope it helps.

这篇关于TFS 为运行任务构建自定义条件 - 检查特定的先前任务是否失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆