...
JobScheduler can manage work flow according to the results of jobs - i.e. their return codes. It can use job return codes to:
...
Jira | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Use Cases
- Welche Rolle ist für den Fall verantwortlich? Wer will etwas? Engineering, Operating, Business
- Was ist das Ziel? Was ist das Mittel? Was ist die Motivation?
Start one or multiple job chains
Assign Unique Order IDs
Parameter handling
Example Exit code range
Feature Scope
Feature Implementation
The JobScheduler's next_state
(true), error_state
(false) and add_order
commands can also be used to provide a limited control of work flow within a job chain.
Alternative commands
The JobScheduler's next_state
(true), error_state
(false) and add_order
commands can also be used to provide a limited control of work flow within a job chain.
start_order, etc
Status | ||||
---|---|---|---|---|
|
However these commands are job-specific and will be applied every time the job is called, limiting the extent to which the job can be reused.
The implementation described here is specified for a job chain node and is part of the job chain object. The implementation described is therefore independent of the job specified for a node.
Feature Logic
The feature uses the inverse logic of exit codes: an exit code of 0 is returned when a job has run successfully and all other exit codes (i.e. non 0) are returned when a job ends in error.
...
feature uses the inverse logic of return codes: an exit code of 0 is returned when a job has run successfully and all other return codes (i.e. non 0) are returned when a job ends in error.
The feature has been implemented to use individual return codes (0, 1, 2, etc) or return code ranges (1-5, 6-9, etc).
A typical implementation within a job chain would be:
- a return code of 0 will cause an order should go to the next_state in the job chain.
- a return code between 1 and 5 will cause the order should go to the cleanup_files state.
- a return code between 6 and 9 will cause the order to go to the error state.
A typical implementation:
Alternative commands
The JobScheduler's next_state (true), error_state (false) and add_order commands can also be used to provide a limited control of work flow within a job chain (see the JobScheduler ).
However, these commands are job-specific and will be applied every time the job is called, limiting the extent to which the job can be reused.
The implementation of return_codes is specified for a job chain node and is part of the job chain object. The implementation of return_codes is therefore independent of the job specified for a node and can be used more flexibly than next_state, error_state and add_order.
...
Use Cases
- Welche Rolle ist für den Fall verantwortlich? Wer will etwas? Engineering, Operating, Business
- Was ist das Ziel? Was ist das Mittel? Was ist die Motivation?
Start one or multiple job chains
...
Assign Unique Order IDs
Parameter handling
Example Exit code range
Example: Starting an order according to the exit code returned by a job chain node
Demonstration Files
Download: JobChainReturnCodes Example working example (Windows Version), for Linux simply change the job's shell scripts with Linux scripts.
...
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 ....
Status | ||||
---|---|---|---|---|
|
- 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
...
- 1) Give the return code e.g
. return_code = 0
is success in the ReturnCodes field field- Syntax:
- Individual return codes are separated by blank 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 the job_chain_node/@next_state (return code 0) or job_chain_node/@error_state (other return codes) attribute.
- Syntax:
- 2), 3) Select the target job chain e.g. JobChain1 from the drop down list ( list
- only job chains present 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 an 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
Code Block | ||||
---|---|---|---|---|
| ||||
<job_chain title="JobChain0"> <job_chain_node error_state="Error" job="Job1" next_state="2" state="1"/> <job_chain_node error_state="Error" job="Job2" next_state="3" state="2"/> <job_chain_node error_state="Error" job="Job3" next_state="4" state="3"> <on_return_codes> <on_return_code return_code="0"> <add_order xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="Chain1"/> </on_return_code> </on_return_codes> </job_chain_node> <job_chain_node error_state="Error" job="Job4" next_state="5" state="4"/> <job_chain_node error_state="Error" job="Job5" next_state="6" state="5"/> <job_chain_node error_state="Error" job="Job6" next_state="Success" state="6"/> <job_chain_node state="Success"/> <job_chain_node state="Error"/> </job_chain> |
...
Download: JobChainReturnCodes Example working example ( Windows Version ), for Linux simply change the job's shell scripts with Linux scripts.
...
.
Further Examples
Status | ||||||
---|---|---|---|---|---|---|
|
- Workflow within Job Chain & Error handling
- Setting Parameters and Order Ids
Delimitation
Status | ||||||
---|---|---|---|---|---|---|
|
...
- If an order for another job chain is to be generated in the event of an error occurring in a job ->
- If alternative job chains are to be started depending on the return code (OR) then only one of the alternatives can not result in an error (only one success code poss)
Use Cases
Status | ||||
---|---|---|---|---|
|
Start one or multiple job chains
...
Assign Unique Order IDs
Parameter handling
Example Exit code range
References
...
- job chains are to be started depending on the return code (OR) then only one of the alternatives can not result in an error (only one success code poss)
References
...
- JobScheduler Reference Documentation:
...