...
- the How to configure the handling of exit codes by jobs article
- the JobScheduler <job_chain_node.job_chain> Element reference
Feature comparison
...
The code block below can be opened to show part of the log file for Order0. This shows the log information for Job3 and the start of Job4. The following points are relevant:
- The orderParameter order_parameter value of 0 is shown in Line 56 58 of the listing.
- Line 66 71 shows that Job3 is exiting with return code 0.
- The end of processing of the node for Job3 is noted in line 7072.
- Line 71 74 shows that the state is set for starting Job4 - there is no mention of the generation of the order that will start JobChainB.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
[info] set_state 3, Job /Examples/JobChainReturnCodes_1/Job_3Job3 [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) SCHEDULER-842 Task is going to process Order Examples/JobChainReturnCodes_1/Chain_A:Order 0JobChainA:Order0 "JobJobChainA Chain- Aparameter - ParameterValuevalue 0", state=3, on JobScheduler 'http://AA-Win7:4110', Order's Process_class [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842 - Protocol starts in C:/ProgramData/sos-berlin.com/jobscheduler/jobscheduler_1.10/logs/task.Examples,JobChainReturnCodes_1,Job_3Job3.log [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) SCHEDULER-918 state=starting (at=never) [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) SCHEDULER-987 Starting process Configuration File: "C:\Windows\TEMP\\sos-5C9FA042FB.cmd" 2015-11-05 11:21:01.483+0100 \ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10\config\live\Examples\JobChainReturnCodes\JobChainA.config.xml not found (Probably running on an agent). [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) SCHEDULER-726Reading configuration Taskfrom runs on this xml payload... [info] (Task Examples/JobChainReturnCodes/Job3:92842) SCHEDULER-987 Starting process: "C:\Windows\TEMP\\sos-F7DE9FD90F.cmd" [info] (Task Examples/JobChainReturnCodes/Job3:92842) SCHEDULER-726 Task runs on this JobScheduler 'http://AA-Win7:4110' [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] Job_3Job3 : job starting [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] orderParameterorder_parameter = "0" [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>set /a number=1592528451 %2 +1 [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] Job_3Job3 : sleeping for 2 seconds..... [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>ping 127.0.0.1 -n 2 1>nul [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] Job_3Job3 : job ending exit 0 [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>exit 0 [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6972292842) SCHEDULER-843 Task has ended processing of Order Examples/JobChainReturnCodes_1/Chain_AJobChainA:OrderOrder0 0 "JobJobChainA Chain- Aparameter - ParameterValuevalue 0", state=3, on JobScheduler 'http://AA-Win7:4110' [info] set_state 4, Job /Examples/JobChainReturnCodes_1/Job_4Job4 [info] (Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843) SCHEDULER-842 Task is going to process Order Examples/JobChainReturnCodes_1/Chain_A:Order 0JobChainA:Order0 "JobJobChainA Chain- Aparameter - ParameterValuevalue 0", state=4, on JobScheduler 'http://AA-Win7:4110', Order's Process_class [info] (Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843) [info] (Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843) Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843 - Protocol starts in C:/ProgramData/sos-berlin.com/jobscheduler/jobscheduler_1.10/logs/task.Examples,JobChainReturnCodes_1,Job_4Job4.log [info] (Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843) SCHEDULER-918 state=starting (at=never) [info] (Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843) SCHEDULER-987 Starting process: "C:\Windows\TEMP\\sos-5C9FD94DB4F7DEF0E7B2.cmd" [info] (Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843) [stdout] Job_4Job4 : job starting [info] (Task Examples/JobChainReturnCodes_1/Job_4Job4:6972392843) [stdout] |
The next code block shows part of the log file for Order1. This shows the log information for Job3 and the start of Job6. The following points are relevant:
- Line 66 68 of the listing shows that Job3 is exiting with return code 1.
- Line 69 shows that an error has been logged.
- The end of processing of the node for Job3 is noted in line 70.
- Line 70 shows that an error is loggedLine 71 72 shows that the state is set for starting Job6 - the job at the node specified in the to_state element that was configured for node 3.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
[info] set_state 3, Job /Examples/JobChainReturnCodes_1/Job_3Job3 [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) SCHEDULER-842 Task is going to process Order Examples/JobChainReturnCodes_1/Chain_A:Order 1JobChainA:Order1 "JobJobChainA Chain- Aparameter - ParameterValuevalue 1", state=3, on JobScheduler 'http://AA-Win7:4110', Order's Process_class [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853 - Protocol starts in C:/ProgramData/sos-berlin.com/jobscheduler/jobscheduler_1.10/logs/task.Examples,JobChainReturnCodes_1,Job_3Job3.log [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) SCHEDULER-918 state=starting (at=never) [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) SCHEDULER-987 Starting processConfiguration File: "C:\Windows\TEMP\ProgramData\sos-5CA678D026.cmd" [info] (Task Examples/JobChainReturnCodes_1/Job_3:69730) SCHEDULER-726 Task runs on this JobScheduler 'http://AA-Win7:4110'berlin.com\jobscheduler\jobscheduler_1.10\config\live\Examples\JobChainReturnCodes\JobChainA.config.xml not found (Probably running on an agent). [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] Job_3 : job starting Reading configuration from xml payload... [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) SCHEDULER-987 [stdout] . Starting process: "C:\Windows\TEMP\\sos-F85292D6E1.cmd" [info] (Task Examples/JobChainReturnCodes/Job3:92853) SCHEDULER-726 Task runs on this JobScheduler 'http://AA-Win7:4110' [info] (Task Examples/JobChainReturnCodes/Job3:92853) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] orderParameterJob3 =: "1"job starting [info] (Task Examples/JobChainReturnCodes/Job3:92853) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] . order_parameter = "1" [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3:69730) [stdout] C:\ProgramData\sos [info] (Task Examples/JobChainReturnCodes/Job3:92853) [stdout] [info] (Task Examples/JobChainReturnCodes/Job3:92853) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>set /a number=1607931044 %2 +1 [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] Job_3Job3 : sleeping for 21 seconds..... [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>ping 127.0.0.1 -n 21 1>nul [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] Job_3Job3 : job ending exit 1 [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>exit 1 [ERROR] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) SCHEDULER-280 Process terminated with exit code 1 (0x1) [info] (Task Examples/JobChainReturnCodes_1/Job_3Job3:6973092853) SCHEDULER-843 Task has ended processing of Order Examples/JobChainReturnCodes_1/Chain_A:Order 1JobChainA:Order1 "JobJobChainA Chain- Aparameter -value ParameterValue 1", state=3, on JobScheduler 'http://AA-Win7:4110' [info] set_state 6, Job /Examples/JobChainReturnCodes_1/Job_6Job6 [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) SCHEDULER-842 Task is going to process Order Examples/JobChainReturnCodes_1/Chain_A:Order 1JobChainA:Order1 "JobJobChainA Chain- Aparameter - ParameterValuevalue 1", state=6, on JobScheduler 'http://AA-Win7:4110', Order's Process_class [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854 - Protocol starts in C:/ProgramData/sos-berlin.com/jobscheduler/jobscheduler_1.10/logs/task.Examples,JobChainReturnCodes_1,Job_6Job6.log [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) SCHEDULER-918 state=starting (at=never) [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) SCHEDULER-987 Starting process: "C:\Windows\TEMP\\sos-5CA6B147DFF852B1C77B.cmd" [info] (Task Examples/JobChainReturnCodes_1/Job_6:69731/Job6:92854) [stdout] Job_6 : job starting . [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) [stdout] Job6 : job starting |
The next code block shows the last few lines of the log file for Order1. Line 98 99 of the listing shows that despite the error recorded as Job3 ended, the order is set to the success state.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
[info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) [stdout] .Job6 : job ending [info] (Task Examples/JobChainReturnCodes/Job6:92854) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6973192854) [stdout] Job_6 : job ending SCHEDULER-915 Process event [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:69731) [stdout] . [info] (Task92854) SCHEDULER-843 Task has ended processing of Order Examples/JobChainReturnCodes_1/Job_6:69731) SCHEDULER-915 Process event [info] (Task Examples/JobChainReturnCodes_1/Job_6:69731) SCHEDULER-843 Task has ended processing of Order Examples/JobChainReturnCodes_1/Chain_A:Order 1 "Job Chain A - ParameterValue JobChainA:Order1 "JobChainA - parameter value 1", state=6, on JobScheduler 'http://AA-Win7:4110' [info] set_state Success [info] SCHEDULER-944 End state reached - order will be repeated at 2038-01-19 03:14:07.000Z with state=1 [info] SCHEDULER-962 Protocol ends in C:/ProgramData/sos-berlin.com/jobscheduler/jobscheduler_1.10/logs/order.Examples,JobChainReturnCodes_1,Chain_A.Order 1JobChainA.Order1.log |
Part of the log file for JobChainB, which only starts when Order0 is run, is shown in the next code block. Only the log information for Job6 is shown in the listing. It can be seen that:
- The ID from the order generating the order for has been taken over by default. This is shown in the listing in line 5124.
- The orderParameter order_parameter value from Order0 on JobChainA has also been taken over and shown in line 3836.
- The ParameterJob3 parameter_job_3 parameter, which is set with value "Parameter from Job3 - RC=0ParameterReturnCodeJob3" is shown in line 3533. This parameter was set in the on_return_code element at the node for Job3 in JobChainA.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
[info] set_state 2, Job /Examples/JobChainReturnCodes/Job6 [info] (Task Examples/JobChainReturnCodes/Job6:92845) SCHEDULER-842 Task is going to process Order Examples/JobChainReturnCodes/JobChainB:Order0, state=2, on JobScheduler 'http://AA-Win7:4110', Order's Process_class [info] (Task Examples/JobChainReturnCodes/Job6:92845) [info] (Task Examples/JobChainReturnCodes/Job6:92845) Task Examples/JobChainReturnCodes/Job6:92845 - Protocol starts in C:/ProgramData/sos-berlin.com/jobscheduler/jobscheduler_1.10/logs/task.Examples,JobChainReturnCodes,Job6.log [info] (Task Examples/JobChainReturnCodes/Job6:92845) SCHEDULER-918 state=starting (at=never) [info] (Task Examples/JobChainReturnCodes/Job6:92845) SCHEDULER-987 Starting process: "C:\Windows\TEMP\\sos-F7DF14AB5D.cmd" [info] (Task Examples/JobChainReturnCodes/Job6:92845) [stdout] Job6 : job starting [info] (Task Examples/JobChainReturnCodes/Job6:92845) [stdout] . [info] (Task Examples/JobChainReturnCodes/Job6:92845) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] Job_6 : job startingC:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>echo parameter_job_3 = "ParameterReturnCodeJob3" [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] .parameter_job_3 = "ParameterReturnCodeJob3" [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>echo ParameterJob3order_parameter = "Parameter from Job3 - RC=0" "3" [info] (Task Examples/JobChainReturnCodes/Job6:92845) [stdout] order_parameter = "3" [info] (Task Examples/JobChainReturnCodes_1/Job_6:69725) [stdout] ParameterJob3 = "Parameter from Job3 - RC=0"Job6:92845) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>echo10>set orderParameter/a number= "0"28461 %2 +1 [info] (Task Examples/JobChainReturnCodes/Job6:92845) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] orderParameter = "0" Job6 : sleeping for 2 seconds..... [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>set /a number=15932 %2 +1 [info] (Task Examples/JobChainReturnCodes_1/Job_6:69725) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_6:69725) [stdout] Job_6 : sleeping for 1 seconds.....10>ping 127.0.0.1 -n 2 1>nul [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] Job6 [info]: job (Task Examples/JobChainReturnCodes_1/Job_6:69725) [stdout] C:\ProgramData\sos-berlin.com\jobscheduler\jobscheduler_1.10>ping 127.0.0.1 -n 1 1>nul ending [info] (Task Examples/JobChainReturnCodes/Job6:92845) [stdout] . [info] (Task Examples/JobChainReturnCodes_1/Job_6Job6:6972592845) [stdout] . SCHEDULER-915 Process event [info] (Task Examples/JobChainReturnCodes/Job6:92845) SCHEDULER-843 Task has ended processing of Order Examples/JobChainReturnCodes/JobChainB:Order0, state=2, on JobScheduler 'http://AA-Win7:4110' [info] set_state Success [info] SCHEDULER-945 No further job in job chain - order has been carried out [info] (Task Examples/JobChainReturnCodes_1/Job_6:69725) [stdout] Job_6 : job ending SCHEDULER-940 Removing order from job chain |
Configuring the example return codes
This is done in the Nodes tab of the JobScheduler Object Editor JOE for JobChain0 as shown in Screenshot 1 below.
(A more detailed description of how to use JOE to configure a job chain can be found in JobScheduler Tutorial 2 - Editing a Simple Job with JOE.)
- The standard progression through the job chains is configured in the NextState and ErrorState fields of the form.
- Generation of the order to start JobChain1 is configured as shown in the screenshot:
- 1) Select Job3 since we want to start JobChain1 if this job ends successfully
- 2) Click on the Return Codes button to open the Return Code configuration form
Screenshot 1
- 1) Give the return code, e.g
. return_code = 0
signals success, in the ReturnCodes field- Syntax:
- Individual return codes are separated by spaces (e.g. 1 2).
- Return code ranges are inclusive and written 1..5 6..9
- Return codes can only be specified once
- Behavior:
- Note that non-zero return codes can be used but will be seen as an errors in the originating job chain.
- Should no
<on_return_code>
element match the current return code then JobScheduler will apply thejob_chain_node@next_state
(return code 0) orjob_chain_node@error_state
(other return codes) attribute.
- Syntax:
- 2), 3) Select the target job chain e.g. JobChain1 from the drop down list
- only job chains present in the same folder will be available in the Job Chain dropdown list
- Other job chains can be:
- navigated to using the Browse button.
- specified using the syntax:
/myFolder/myJobChain.
- 4) Click on Add Order button to assign the Order to the
JobChain1
- 5) Click on Apply (at the foot of the form)to make the changes in the job chain configuration
- Save the job chain configuration.
Screenshot 2
Example Job Chain Code
...
Limitations of use
Overlapping return codes
Avoid creating overlapping return codes and/or overlapping return code ranges.
- Overlapping return codes should not be used to create multiple orders.
This is automatically corrected in JOE but is possible when configuration is carried out with a code editor.
Example:Code Block language xml title Example showing 'overlapping' of return-codes collapse true <!-- do not use overlapping return codes --> <on_return_code return_code="3"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainC"/> </on_return_code> <on_return_code return_code="3"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainD"/> </on_return_code> <!-- use mutliple add_order elements for the same return code --> <on_return_code return_code="3"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainC"/> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainD"/> </on_return_code>
...
Overlapping return code ranges should not be be used.
This is currently possible in JOE (versions 1.9.7, 1.10.1).Example:
Code Block language xml title Example showing 'overlapping' of return-code ranges collapse true <!-- do not use overlapping return code ranges --> <on_return_code return_code="3"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainC"/> <to_state state="6"/> </on_return_code> <on_return_code return_code="1..3"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainD"/> </on_return_code> <!-- use a number of return code configurations --> <on_return_code return_code="3"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainC"/> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainD"/> <to_state state="6"/> </on_return_code> <on_return_code return_code="1..2"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="JobChainD"/> </on_return_code>
<on_return_code> matching limitations
...
JobScheduler executes on_return_code elements one after the other and executes any element containing a to_state attribute first. This means that of a job ends with a return code that is matched by a number of on_return_code elements, only the element with a to_state attribute will be executed as once this has been done, the order will no longer be at the original state to execute any further on_return_code elements.
...
References
Change Management References
...