How to gracefully stop job execution when one step fails in Rundeck?

 ̄綄美尐妖づ 提交于 2020-01-05 06:37:31

问题


So I defined a Rundeck job which normally executes three steps:

  1. run script to check remote directory for .csv files and rsync them
  2. manipulate csv files
  3. rsync the csvs back to remote dir

now I set up the script run on step 1 to finish with exit code 1 when there are no csv files in my remote directory, upon which it does not execute steps 2 and 3 - which is great! But the whole job is marked as having failed even though it just didn't need to execute the other steps.

Is it possible to conditionally execute steps 2 and 3 of my job such that if step 1 fails it is still marked as 'succeeded'?


回答1:


It is possible with Rundeck Error Handlers.

You will need to use the job context variable ${result.resultCode} in your error handler code in order to get a return code.

As you don't want the job marked as failed after the Error Handler was successfully executed, you need to tick Keep going on success from WebUI or add keepgoingOnSuccess="true" to you job definition code.

But after the error handler was successfully executed, the job will continue step 2 and step 3, where you may need to inject your step 2 code for it.



来源:https://stackoverflow.com/questions/41729610/how-to-gracefully-stop-job-execution-when-one-step-fails-in-rundeck

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!