Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

Introduction

Display feature availability
StartingFromRelease2.4.0

The JITL CheckHistoryJob template can be used to check past executions of workflows and jobs.

  • 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 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.

...

You can use the job wizard like this:


Explanation:

  • Add an empty job from the instruction panel.
  • Specify a name and a label for the job.
  • Select an Agent.

...

  • the history status of orders or jobs:
    • completed: the order or job completed successfully or failed.
    • completed successful
    • completed failed
  • the period for which the execution history is looked up for orders and jobs that
    • started between two dates
    • completed between two dates
    • with periods being specified as absolute or relative dates

...

Syntax

Queries are specified from a function and optional arguments.

Functions

FunctionArgumentsDefault
SyntaxExplanation
<function>Functions can be used without arguments by stating exclusively the name of the function.
<function>( argument[, argument] )Functions can optionally be specified with one or more arguments that are separated by commas.

Functions

FunctionArgumentsDefaultExplanation
isStartedstartedFrom,
startedTo, count
startedFromisStartedstartedFrom,
startedTo, count
startedFrom=0d, startedTo=0d,  count=1
  • Scope: specifies that the workflow or job started without consideration if it completed or is still running.
  • Default Period: start on the same day.
isCompletedstartedFrom,
startedTo, completedFrom, completedTo, count
completedFrom=0d, completedTo=0d,  count=1
  • Scope: specifies that the workflow or job completed without consideration of success of failure.
  • Arguments: if the argument startedFrom is specified, then the default value of the startedTo argument is 0d.
  • Default Period: start and completion on the same day.
isCompletedSuccessfulstartedFrom,
startedTo, completedFrom, completedTo, count
completedFrom=0d, completedTo=0d,  count=1
  • Scope: specifies that the workflow or job completed successfully.
  • Arguments: if the argument startedFrom is specified, then the default value of the startedTo argument is 0d.
  • Default Period: start and completion on the same day.
isCompletedFailedstartedFrom,
startedTo, completedFrom, completedTo, count
completedFrom=0d,  completedTo=0d, count=1
  • Scope: specifies that the workflow or job failed.
  • Arguments: if the argument startedFrom is specified, then the default value of the startedTo argument is 0d.
  • Default Period: start and completion on the same day.
lastCompletedSuccessfulstartedFrom,
startedTo, completedFrom, completedTo, count
completedFrom=0d,  completedTo=0d, count=1
  • Scope: specifies that the last run of the job completed successfully.
  • Arguments: if the argument startedFrom is specified, then the default value of the startedTo argument is 0d.
  • Default Period: start and completion on the same day.
lastCompletedFailedstartedFrom,
startedTo, completedFrom, completedTo, count
completedFrom=0d,  completedTo=0d, count=1
  • Scope: specifies that the last run of the workflow or job failed.
  • Arguments: if the argument startedFrom is specified, then the default value of the startedTo argument is 0d.
  • Default Period: start and completion on the same day.
lastCompletedSuccessful

Arguments

ArgumentDefaultExplanation
startedFrom
,
startedTo, completedFrom, completedTo, countcompletedFrom=0d,  completedTo=0d, count=1
  • 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 the startedTo argument is 0d.
  • Default Period: start and completion on the same day.

Arguments

The workflow or job started after startedTo
0dThe workflow or job started after the given date.
startedTo0dThe workflow or job started before the given date.
completedFrom0dThe workflow or job completed after the given date.
completedTo0dThe workflow or job completed before
ArgumentDefaultExplanation
startedFrom0d the given date.
count0dThe workflow or job started before the given date.
completedFrom0dThe workflow or job completed after the given date.
completedTo0dThe workflow or job completed before the given date.
1The minimum number of history count1The minimum number of history items that is expected to be returned for the given period. By default a single history item is expected. The CheckHistoryJob will fail if the number of expected history entries specified by this argument exceeds the number of history items returned.

Syntax 

...

Absolute Dates

Absolute date can be

Absolute Dates

Absolute date can be specified as values to the startedFrom, startedTo, completedFrom and completedTo arguments.

...

ExampleExplanation
isStartedSpecifies that the workflow or job started today.
isCompletedSpecifies that the workflow or job completed today independently from its start date.
isCompletedSuccessfulSpecifies that the workflow or job completed successfully today independently from its start date.
isCompletedFailedSpecifies 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.
lastCompletedSuccessfulSpecifies that the last run of the workflow or job completed successfully.
lastCompletedFailedSpecifies 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.

...

The Job Documentation including the full list of arguments can be found underfromhttps://www.sos-berlin.com/doc/JS7-JITL/CheckHistoryJob.xml

Anchor
arguments
arguments
Arguments

The CheckHistoryJob template accepts the following arguments:

NameRequiredDefault ValuePurpose
queryyesn/a

Specifies the expression that is used to look up the execution history, for example isCompleted, isCompletedSuccessful etc., for the full list see Queries.

workflow

non/a

Specifies the name of a workflow for which the execution history is looked up. A workflow name or job name has to be specified.

jobnon/aSpecifies the name of a job for which the execution history is looked up. A workflow name or job name has to be specified.
controller_idnon/aThe identifier of a Controller can be specified to limit results to workflows and jobs executed with the indicated Controller.

Anchor
return_variables
return_variables
Return Variables

The CheckHistoryJob template returns the following variables:

Return VariableData TypePurposeExample
js7CheckHistoryResultBoolean

Returns the Boolean result of the query.
Note: The query result is similarly returned with the returnCode return variable and the values 0=true, 1=false.

true, false

js7CheckHistoryResultControllerId

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
js7CheckHistoryResultWorkflowString

Returns the workflow name 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 workflow name of the youngest resulting history entry.

check_history
js7CheckHistoryResultStartedjs7CheckHistoryResultJobDateString

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.
If the query returns a result then the return variable holds the start date and time job name of the youngest resulting history entry in ISO-8601 format.

2012check-12-05T01:00:00+02:00history-job
js7CheckHistoryResultStartedjs7CheckHistoryResultCompletedDate

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
js7CheckHistoryQueryjs7CheckHistoryResultCompletedStringDate

Returns the value completion date and time of the query argumentresulting history entry.Returns a copy

The value of the value of the query argument that was used with the query.return variable is empty if the query returns no result. If the query returns a result then the return variable contains the completion date and time of the youngest resulting history entry in ISO-8601 format.

2012-12-05T01:00:00+02:00
js7CheckHistoryQueryisStartedjs7CheckHistoryQueryWorkflowString

Returns the value of the workflow query argument.

Returns a copy of the value of the workflow query argument that was used with the query.

accountingisStarted
js7CheckHistoryQueryJob

js7CheckHistoryQueryControllerId

String

Returns the value of the job controller_id argument.

Returns a copy of the value of the job argument controller_id argument that was used with the query.

my-jobcontroller

Authentication

api-server {
# API Server URL
url = "https://joc-2-0-secondary:4443"

# Use of Credential Store
cs-file=${js7.config-directory}"/private/secret.kdbx"
cs-key=${js7.config-directory}"/private/secret.key"
cs-password="secret"
account="/myAccounts/joc@username"
password="/myAccounts/joc@password"

# Use of account and password
# account="root"
# password="root"
}

Job Dependencies

The CheckHistoryJob template can be used to implement job dependencies 

...

js7CheckHistoryQueryWorkflowString

Returns the value of the workflow argument.

Returns a copy of the value of the workflow argument that was used with the query.

accounting
js7CheckHistoryQueryJobString

Returns the value of the job argument.

Returns a copy of the value of the job argument that was used with the query.

my-job

Job Dependencies

The CheckHistoryJob template can be used to implement backward job dependencies:

  • Jobs based on the CheckHistoryJob template do not fail if the underlying query does not return results.
  • Instead, the CheckHistoryJob template provides Return Variables that can be inspected to determine further execution of jobs in a workflow.
  • JS7 offers the JS7 - If Instruction to check the values of Return Variables and to decide what instructions to execute next.

Download (upload .json): pdwCheckHistory.workflow.json

Image Added


Explanation:

  • Arguments of the CheckHistoryJob template include to specify the query and workflow that is looked up in the execution history.
  • The query isCompletedSuccessful checks if the indicated workflow was successfully executed during the current day.

Image Added


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:

        Image Added

      • the job script can make use of environment variables like this:

        Image Added

    • If the successor job is a JVM job then Return Variables can be accessed directly.

Further Resources