繁体   English   中英

在特定步骤中停止 rundeck 工作流

[英]Stop rundeck workflow in a specific step

有没有办法在特定步骤停止工作流?

例如,如果我有一个 5 个步骤的工作流,我如何在步骤 2(不执行步骤 3、4 和 5)上停止工作流(具有成功状态)?

非常感谢 :-)

您可以使用Flow Control 插件作为一个步骤:在您的作业中,您可以在名为“Flow Control”的步骤之间添加一个新的 Workflow 步骤,以在任何步骤停止作业。

我留下了一个工作定义示例:

<joblist>
  <job>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>c84e6ac0-3bb1-4021-9924-0603cf9ddc22</id>
    <loglevel>INFO</loglevel>
    <name>JobEXAMPLE</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <plugins />
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <exec>echo "step one"</exec>
      </command>
      <command>
        <exec>echo "step two"</exec>
      </command>
      <command>
        <step-plugin type='flow-control'>
          <configuration>
            <entry key='fail' value='false' />
            <entry key='halt' value='true' />
          </configuration>
        </step-plugin>
      </command>
      <command>
        <exec>echo "step three"</exec>
      </command>
      <command>
        <exec>echo "step four"</exec>
      </command>
      <command>
        <exec>echo "step five"</exec>
      </command>
    </sequence>
    <uuid>c84e6ac0-3bb1-4021-9924-0603cf9ddc22</uuid>
  </job>
</joblist>

结果在这里

或者,您可以在下面的示例中使用 Rundeck(基本上是“脚本”),我使用了一个文件内容,如标志,该值在每个步骤中进行评估(在第三个步骤中有意更改):

<joblist>
  <job>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>8f31dee3-255b-4adb-a884-9cd3cce39a65</id>
    <loglevel>INFO</loglevel>
    <name>JobEXAMPLE</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <plugins />
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='sequential'>
      <command>
        <exec>echo "1" &gt; file</exec>
      </command>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[value=$(cat file)

if [ $value = 1 ]; then
   echo "i am the first step..."
fi]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[value=$(cat file)

if [ $value = 1 ]; then
   echo "i am the second step..."
fi]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[# intentional change to file
echo "0" > file


value=$(cat file)

if [ $value = 1 ]; then
   echo "i am the third step..."
fi]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[value=$(cat file)

if [ $value = 1 ]; then
   echo "i am the fourth step..."
fi]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
      <command>
        <fileExtension>.sh</fileExtension>
        <script><![CDATA[value=$(cat file)

if [ $value = 1 ]; then
   echo "i am the fifth step..."
fi]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
      <command>
        <exec>echo "done!"</exec>
      </command>
    </sequence>
    <uuid>8f31dee3-255b-4adb-a884-9cd3cce39a65</uuid>
  </job>
</joblist>

检查结果

我遇到了同样的问题,我没有找到任何合适的解决方案,所以我通过添加条件创建了插件“流控制”的一个分支。

也许你有兴趣: https : //github.com/Ookami-Git/conditional-flow-control-plugin

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM