snippetMinor
How to send notification only in case of job output being non-empty
Viewed 0 times
casenonjobemptyoutputbeinghowsendonlynotification
Problem
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.
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.
Solution
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.
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.
Context
StackExchange DevOps Q#284, answer score: 7
Revisions (0)
No revisions yet.