首页 > 解决方案 > 在 Rundeck 作业失败通知中禁用 NonZeroResultCode 状态详细信息

问题描述

在作业失败(退出代码 > 0)时,Rundeck 会自动将详细的状态信息添加到通知附件中:

Failed: NonZeroResultCode: Remote command failed with exit status 1
Execution failed: 3709 in project test_project_1: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [host1: NonZeroResultCode: Remote command failed with exit status 1 + {dataContext=MultiDataContextImpl(map={ContextView(step:1, node:host1)=BaseDataContext{{exec={exitCode=0}}}, ContextView(node:host1)=BaseDataContext{{exec={exitCode=0}}}}, base=null)} ]}, Node failures: {host1=[NonZeroResultCode: Remote command failed with exit status 1 + {dataContext=MultiDataContextImpl(map={ContextView(step:1, node:host1)=BaseDataContext{{exec={exitCode=0}}}, ContextView(node:host1)=BaseDataContext{{exec={exitCode=0}}}}, base=null)} ]}, status: failed]

是否可以通过禁用/隐藏此消息仅发送成功作业运行时的附件中的脚本输出?

标签: rundeck

解决方案


您可以在您的步骤中强制“退出 0”,将其包装在像这样的一些内联脚本上

#!/bin/bash

touch /root/test 2> /dev/null

if [ $? -eq 1 ]
then
  # whatever you want
  echo "Successfully created file"
  exit 0
else
  echo "Could not create file" >&2
  exit 1
fi

推荐阅读