Page History
...
- The job template makes use of the JS7 - REST Web Service API to retrieve information from the JS7 - History. Operation of the job template requires
- network access from the Agent that executes the job to the JOC Cockpit instance,
- availability of the Controller and of JOC Cockpit,
- authentication and authorization with JOC Cockpit.
- The job template authenticates with the JS7 - REST Web Service API by use of user account/password and/or by use of a certificate, for details see JS7 - Authentication.
- For details about configuration items see JS7 - JITL Common Authentication.
- The job template checks the execution history of workflows and jobs
- for execution with a start date or completion date in the given period,
- for successful or failed execution results.
...
Function | Arguments | Default | Explanation |
---|---|---|---|
isStarted | startedFrom, startedTo, count | startedFrom=0d, startedTo=0d, count=1count>0 |
|
isCompleted | startedFrom, startedTo, completedFrom, completedTo, count | completedFrom=0d, completedTo=0d, count=1 count>0 |
|
isCompletedSuccessful | startedFrom, startedTo, completedFrom, completedTo, count | completedFrom=0d, completedTo=0d, count=1count>0 |
|
isCompletedFailed | startedFrom, startedTo, completedFrom, completedTo, count | completedFrom=0d, completedTo=0d, count=1count>0 |
|
lastCompletedSuccessful | startedFrom, startedTo, completedFrom, completedTo, count | completedFrom=0d, completedTo=0d, count=1count>0 |
|
lastCompletedFailed | startedFrom, startedTo, completedFrom, completedTo, count | completedFrom=0d, completedTo=0d, count=1count>0 |
lastCompletedSuccessful |
Arguments
Argument | Default | Explanation |
---|---|---|
startedFrom |
startedTo, completedFrom, completedTo, count
completedFrom=0d |
- Scope: specifies that the last run of the workflow or job completed successfully.
- Arguments: if the argument
startedFrom
is specified, then the default value of thestartedTo
argument is0d
. - Default Period: start and completion on the same day.
Arguments
The workflow or job started after the |
startedFrom
0d
given date. | ||
startedTo | 0d | The workflow or job started before the given date. |
completedFrom | 0d | The workflow or job completed after the given date. |
completedTo | 0d | The workflow or job completed before the given date. |
count
count |
1
count>0 | Count is used with an operator. The number of history items that is expected to be returned for the given period. By default |
at least one history item is expected ( |
not correspond to the number of history items returned. Values for operator: =, <=, <, >, >= Example count > 10 ==> The CheckHistoryJob will fail if the number of history entries is not greater then 10 |
Absolute Dates
Absolute date can be specified as values to the startedFrom
, startedTo
, completedFrom
and completedTo
arguments.
...
Example | Explanation |
---|---|
isStarted | Specifies that the workflow or job started today. |
isCompleted | Specifies that the workflow or job completed today independently from its start date. |
isCompletedSuccessful | Specifies that the workflow or job completed successfully today independently from its start date. |
isCompletedFailed | Specifies that the workflow or job failed today independently from its start date. |
isCompleted( startedFrom=0d ) | Specifies that the workflow or job started today and completed today. It is not considered if the workflow or job completed successfully or failed. |
isCompletedSuccessful( startedFrom=0d ) | Specifies that the workflow or job started today and completed successfully today. |
isCompletedFailed( startedFrom=0d ) | Specifies that the workflow or job started today and failed today. |
isStarted( startedFrom=2021-12-05T01:00:00+02:00 ) | Specifies that the workflow or job started after the given point in time. |
isCompletedSuccesfulisCompletedSuccessful( startedFrom=2021-12-05T01:00:00+02:00 ) | Specifies that the workflow or job started after the given point in time and completed successfully. |
isCompletedFailed( startedFrom=2021-12-05T01:00:00+02:00 ) | Specifies that the workflow or job started after the given point in time and failed. |
isCompleted( completedFrom=2021-12-05T01:00:00+02:00 ) | Specifies that the workflow or job completed after the given point in time. |
isCompletedSuccessful( completedFrom=2021-12-05T01:00:00+02:00 ) | Specifies that the workflow or job completed successfully after the given point in time. |
isCompletedFailed( completedFrom=2021-12-05T01:00:00+02:00 ) | Specifies that the workflow or job failed after the given point in time. |
isCompleted( completedFrom=2021-12-05T01:00:00.000Z, completedTo=2022-05-05T01:00:00+02:00 ) | Specifies that the workflow or job completed before the given point in time. |
isCompletedSuccesfulisCompletedSuccessful( completedFrom=2021-12-03T01:00:00+02:00, completedTo=2021-12-05T01:00:00+02:00 ) | Specifies that the workflow or job completed successfully before the given point in time. |
isCompletedFailed( completedFrom=2021-12-04T01:00:00+02:00, completedTo=2022-12-05T01:00:00+02:00 ) | Specifies that the workflow or job failed before the given point in time. |
lastCompletedSuccessful | Specifies that the last run of the workflow or job completed successfully. |
lastCompletedFailed | Specifies that the last run of the workflow or job failed. |
lastCompletedSuccessful( startedFrom=-11d, startedTo=-1d ) | Specifies that the last run of the workflow or job started in the given period and completed successfully today. |
lastCompletedFailed( startedFrom=-11d, startedTo=-1d ) | Specifies that the last run of the workflow or job started in the given period and failed today. |
lastCompletedSuccessful( completedFrom=-11d, completedTo=-1d ) | Specifies that the last run of the workflow or job completed successfully in the given period. |
lastCompletedFailed( completedFrom=-11d, completedTo=-1d ) | Specifies that the last run of the job failed in the given period. |
...
Return Variable | Data Type | Purpose | Example | ||||
---|---|---|---|---|---|---|---|
js7CheckHistoryResult | Boolean | Returns the Boolean result of the query. | true, false | ||||
| String | Returns the Controller ID of the resulting history entry. The value of the return variable is empty if the query returns no result. If the query returns a result then the return variable holds the Controller ID of the youngest resulting history entry. | controller | ||||
js7CheckHistoryResultWorkflow | String | Returns the workflow name of the resulting history entry. The value of the return variable is empty if the query returns no result. | check_history | ||||
js7CheckHistoryResultStarted js7CheckHistoryResultJob | DateString | Returns the start date and time job name of the resulting history entry. The value of the return variable is empty if the query returns no result. | 2012check-12-05T01:00:00+02:00 history-job | ||||
js7CheckHistoryResultStarted js7CheckHistoryResultCompleted | Date | Returns the completion start date and time of the resulting history entry. The value of the return variable is empty if the query returns no result. If the query returns a result then the return variable contains holds the completion start date and time of the youngest resulting history entry in ISO-8601 format. | 2012-12-05T01:00:00+02:00 | ||||
js7CheckHistoryQuery js7CheckHistoryResultCompleted | StringDate | Returns the value completion date and time of the The value of the | 2012-12-05T01:00:00+02:00 | ||||
js7CheckHistoryQuery | String | Returns the value of the Returns a copy of the value of the | isStarted | js7CheckHistoryQueryWorkflow | String | Returns the value of the Returns a copy of the value of the | accounting isStarted |
js7CheckHistoryQueryJob
| String | Returns the value of the Returns a copy of the value of the | my-job controller |
...
js7CheckHistoryQueryWorkflow |
...
The CheckHistoryJob template authenticates with the JS7 - REST Web Service API by use of user account/password and/or by use of a certificate, for details see JS7 - Authentication.
...
String | Returns the value of the Returns a copy of the value of the | accounting | |
js7CheckHistoryQueryJob | String | Returns the value of the Returns a copy of the value of the | my-job |
Code Block | ||||
---|---|---|---|---|
| ||||
js7 {
auth { ... }
configuration { ... }
job { ... }
web { ... }
api-server {
# API Server URL
url = "https://joc-2-0-primary:4443"
# Option 1: use of a Credential Store
cs-file=${js7.config-directory}"/private/secret.kdbx"
cs-key=${js7.config-directory}"/private/secret.key"
cs-password="secret"
# Option 1: use of references to credentials
account="cs://myAccounts/joc@username"
password="cs://myAccounts/joc@password"
# Option 2: Use of account and password
# account="root"
# password="root"
}
} |
Explanation:
- The
api-server
configuration section specifies authentication details for the CheckHistoryJob and can occur in any position directly within thejs7
configuration block. - Configuration items available from this configuration section are explained with the following chapters.
Certificate Based Authentication
JS7 - Certificate based Authentication is configured with the ./config/private/private.conf
file:
- The
url
configuration item is required that specifies the URL of the JS7 REST Web Service API. Typically this corresponds to the JOC Cockpit URL.- Users can set up a number of JOC Cockpit instances that are clustered for automated fail-over.
- Users can set up a load balancer that routes requests to a number of available JOC Cockpit instances.
- For use with the CheckHistoryJob template both active and standby JOC Cockpit instances can be used.
- The Client Authentication Certificate has to be available from the keystore file indicated with the
js7.web.https.keystore
orjs7.web.https.client_keystore
settings.- This includes that JOC Cockpit is configured to use a truststore that holds the Root CA Certificate and Intermediate CA Certificate that was used to sign the Agent's Client Authentication Certificate.
- For details see JS7 - JOC Cockpit HTTPS Connections.
User Account / Password Authentication
User account/password authentication is configured with the ./config/private/private.conf
file:
...
- with the following settings:
cs-file:
Specifies the path to a KeePass database file (required).cs-key
: Specifies the path to a KeePass key file (optional).cs-password
: Specifies the password for the KeePass database file (optional).account
: Specifies the path to the entry in the KeePass database that holds the account name (required).password
: Specifies the path to the entry in the KeePass database that holds the password (required).
- that suggest to preferably use a KeePass key file (
cs-key
) to protect the KeePass database. Basically it is pointless to protect a Credential Store by use of a password (cs-password
) that is similarly visible as putting the key under the mat. Use of a key file allows to apply OS ownership and file permissions to protect to the key file from visibility by 3rd parties.
...
account
: Specifies the account name (required).password
: Specifies the plain text password (required).
...
Job Dependencies
The CheckHistoryJob template can be used to implement backward job dependencies:
...
Download (upload .json): pdwCheckHistory.workflow.json
Explanation:
- Arguments of the CheckHistoryJob template include to specify the
query
andworkflow
that is looked up in the execution history. - The query isCompletedSuccessful checks if the indicated workflow was successfully executed during the current day.
Explanation:
- The JS7 - If Instruction is used to check the
$returnValue
return variable that carries- the value 0 if the query of the CheckHistoryJob template returns one or more hits.
- the value 1 if the query of the CheckHistoryJob template returns no hits.
- Alternative solutions include to check the value of the
$js7CheckHistoryResult
return variable for a Boolean value that indicates if the query did return any hits:$js7CheckHistoryResult == true
$js7CheckHistoryResult == false
- The above example executes a successor job based on the result of the CheckHistoryJob. Such jobs have access to any Return Variables:
- If the successor job is a Shell job then
- Return Variables can be mapped to environment variables like this:
- the job script can make use of environment variables like this:
- Return Variables can be mapped to environment variables like this:
- If the successor job is a JVM job then Return Variables can be accessed directly.
- If the successor job is a Shell job then