Fail job based on output

483 views
Skip to first unread message

Mike Smith

unread,
Mar 21, 2018, 1:20:40 PM3/21/18
to rundeck-discuss
I'm pretty new to Rundeck. I have a simple 1 step job that runs a powershell script. If the script can't do it's task it returns false. The job is marked as a success. I'm playing with error handling, but that doesn't seem to do what I want. Can I mark the job failed based on the output of my script?

Ross Patterson

unread,
Mar 21, 2018, 1:23:31 PM3/21/18
to rundeck...@googlegroups.com

If your script generates a non-zero exit status, the job will fail.  “return $false” might be confused with “exit 0” from outside PowerShell (because $false -eq 0), meaning “success”.

 

Ross

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.
To post to this group, send email to rundeck...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/4caf6a2a-5d62-4d8d-bbea-5901d2b192d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Smith

unread,
Mar 21, 2018, 3:01:46 PM3/21/18
to rundeck-discuss
Thanks for the reply. I removed the output (just echoing the parameters) and added Write-Output "1". The script still "succeeds".

Ross Patterson

unread,
Mar 21, 2018, 3:07:37 PM3/21/18
to rundeck...@googlegroups.com

To be clear: It’s the script’s exit status that Rundeck cares about, nothing else.  Try this:

 

if ($TheThingWereTryingToDoDidntWork) {

              exit 1

Mike Smith

unread,
Mar 21, 2018, 3:18:42 PM3/21/18
to rundeck-discuss
That did the trick, Thanks Ross!
Reply all
Reply to author
Forward
0 new messages