We are using rundeck to scan logfiles for a service, and take action depending on what is found there. Basically, for each item found, for which a records does not exists, a git repository is initialized and a few rest endpoints are called, but that's not the point.

We are setting up the job to run as scheduled, say every couple of hours, and to send notification on failure, and additionally to send notification on success only when at least one action has been taken (ie. the shell script in the task entered the loop at least once). The script is written so that it only emits output on stdout when items to be actioned are found.

Is there a way in rundeck to trigger notification with this requirement? Or a way to script it without writing a plugin from scratch?

One possible workaround would be to switch the failure notification trigger off, and make the script return non-zero in case of no items actioned, but I am not comfortable in doing that.

  • Is the output really empty, or could it have some blanck lines or a carriage return ? – Tensibai Mar 3 '17 at 13:17
  • afaics it's empty, from a bash perspective; there is a single shell step with my script, not sure i rundeck would decorate it with output around – ᴳᵁᴵᴰᴼ Mar 3 '17 at 13:30
  • Would sending the notification from the script itself be an option ? And so rundeck only notify on failure and the script does its own "I did something" notification ? – Tensibai Mar 3 '17 at 13:39
  • That's actually a good idea! – ᴳᵁᴵᴰᴼ Mar 3 '17 at 13:52
up vote 5 down vote accepted

The way I could think of are:

Writing your own plugin, from the notification plugin example page, adapting the example mail notification code could be a way.

Disabling success notifications in rundeck, and handle the success notification part in your script itself. This way that's your script responsibility to warn it did something in normal state and it's still rundeck responsibility to warn you the script failed.

  • 1
    Thanks; when you get a feature wrapped up by the tool you have in front, it is so common sometimes to forget you can go for it directly.... – ᴳᵁᴵᴰᴼ Mar 3 '17 at 14:23

I was able to get around this issue in a bit of a dodgy way by changing the command to:

/bin/bash -c "your-command-here | { ! grep '^'; }"

This pipes the output through grep and fails if there is any output at all, but grep still passes it through so you still get to see the output in Rundeck upon failure.

One drawback is that I believe you lose any blank lines but we don't output any so no big deal for us, and it will tide us over until we can update the app to terminate with a proper exit code.

New contributor
Malvineous is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.