Skip to main content

Rundeck 4.8.0 community version on Redhat 9 Linux with Windows node. My Rundeck jobs call powershell (.ps1) scripts on the windows node as a command. For example :


Command : E:\\Scripts\\test.ps1 -name ${option.name} -address ${option.address}


If there are any errors encountered in the script, the Rundeck job dies. The rundeck output gives the NonZeroResultCode message


NonZeroResultCode: [WinRMPython] Result code: 1


There’s more code that needs to be run after where the error occurred, but Rundeck just dies and doesn’t continue the rest of the .ps1.


I previously used Rundeck version 3.something, I thing it was 3.9.


If there was an error in the script, such as a get or a set failed, the Rundeck console would just display the text of the error in red, and continue.


Now I know I can change my code and add try/catch statements, -erroraction SilentlyContinue and so on. However it makes no sense to me that Rundeck takes it upon itself to kill my script because a get or a set failed.


I want to be the one to decide if I want to exit the script or not, I don’t want Rundeck to make that decision.


Can this behavior be changed?

There is the error handling feature, I read the docs, but I cannot figure out how to use that with an error inside the powershell script.


/ERROR ] Execution finished with the following error (winrm-exec.py:323)yroot]

bERROR ] Performing the operation “New” on target … blah blah blah … etc

Failed: NonZeroResultCode: rWinRMPython] Result code: 1


thanks in advance

Hi Roger,


That’s the Rundeck behavior. In that case, you have the option to capture errors in Rundeck, the first one is to attach Error handlers I the job fails, but checking your original question here it seems that you need a specific behavior in case of a specific error so, the best approach is to add to your script some code to “catch” the error and keep executing with a specific behavior (as you said).


Greetings!


Reiner, you can’t keep answering my questions with my own posts. I post in a few places to get more exposure. I’m still looking for an error handler for errors inside powershell scripts … if that is even a thing.


Rundeck also throws error because of verbose output



Reply