VSTS - 有没有办法只在特定任务失败时运行任务? [英] VSTS - Is there a way to only run a task if a specific task has failed?

查看:29
本文介绍了VSTS - 有没有办法只在特定任务失败时运行任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的构建定义中运行发布任务,但前提是某个任务失败之前.如果其他任务通过,我希望它被忽略而不运行.

有没有办法做到这一点?

我希望我可以根据任务成功设置一个输出变量,然后在自定义条件中使用该变量在任务失败时运行该任务.

如果任务失败,我看不到如何设置输出变量.这可能吗?

解决方案

  • 在任务设置中展开控制选项"
  • 在运行此任务"中选择 - 仅当前一个任务失败时.

如果您只想在最后/特定任务失败时运行任务:

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

  • 定义一个

    I need to run a publish task in my build definition but only if a certain task before it has failed. If the other task passes I want this to be ignored and not run.

    Is there a way of doing this?

    I was hoping that I could set an output variable based on the task success and then use that variable in a custom condition to run the task if it's failed.

    I can't see how to set an output variable if the task fails. Is this possible?

    解决方案

    • In the Task settings expand the "Control Options"
    • Choose in "Run this task" - Only when a previous task has failed.

    If you want to run the task only if last/specific task failed:

    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.

    • 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')

    这篇关于VSTS - 有没有办法只在特定任务失败时运行任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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