rundeck 工作流的行为与“在失败的步骤停止”和“并行策略”

问题描述

场景:通过 2 个步骤创建 rundeck 工作流

  • 第一步
  • 步骤 2

将“如果步骤失败”的选项设置为“在失败的步骤处停止”。 将“策略”选项设置为“并行”

假设 Step1 和 Step2 是长时间运行的过程,所有 2 个步骤同时开始执行。所以我需要知道上面的设置,如果 Step1 失败了,但 Step2 没有完成就继续运行。

Rundeck 会在 Step1 失败后立即在主活动窗口中触发失败结果,还是等待 Step2 完成运行?

无论 Step1 或 Step2 失败,有没有办法强制 rundeck 在 Step1 和 Step2 都完成后在主活动中触发失败的结果。

谢谢。

解决方法

是的,这是 Rundeck 的默认行为。

但是,您可以使用内联脚本步骤(“脚本”步骤)来执行一些脚本操作。

这个想法是同时启动两个任务并在两个任务完成后报告作业失败。我留下了一个工作定义示例,请随意修改。

工作定义示例:

<joblist>
  <job>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>4e5e03b7-4d9d-404c-9ebe-7adbcc178d2f</id>
    <loglevel>INFO</loglevel>
    <name>HelloWorld</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <plugins />
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='true' strategy='parallel'>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[# just a simulation of two paralell task on bash
sleep 10; eco "first task"; status=$(echo $? &) # this task has a intentional error to test the script
sleep 20; echo "second task"; status=$(echo $? &)

# just for debug
echo "whole status is: $status"

# and depending of the result,the job fails (or not) *after* the two tasks
if [ $status -ne 0 ]; then
    exit 1
else
    exit 0
fi]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
    </sequence>
    <uuid>4e5e03b7-4d9d-404c-9ebe-7adbcc178d2f</uuid>
  </job>
</joblist>

如果退出代码非零,rundeck 作业总是失败。