Details
-
Feature
-
Status: Released (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
Description
Current Situation
The check run history function does not support
- time limits
- job chains
- orders
Desired Behaviour
The check run history function should support
- time limits
- job chains
- orders
Feature
see https://change.sos-berlin.com/browse/JITL-217, additionally
-
- Time limits can be given
- var jobHistoryInfo = jobHistory.getJobInfo("job1","-8:10:00:00..-4:14:00:00");
- int getCount());
- int getNumberOfCompleted()
- int getNumberOfCompletedSuccessful()
- int getNumberOfCompletedWithError()
- int getNumberOfStarts());
- boolean isCompletedBefore
- boolean isCompletedWithErrorBefore
- boolean isCompletedSuccessfulBefore
- Time limits can be given
function spooler_process() { // using the current job name and default limit var jobChainHistoryInfo = getjobChainHistoryInfoObject("test"); // using the current job chain name and the given limit // var jobChainHistoryInfo = getjobChainHistoryInfoObject( "", 30 ); // using the given job chain name and default limit // var jobChainHistoryInfo = getjobChainHistoryInfoObject( "jobchain1" ); // using the given job chain name and the given limit // var jobChainHistoryInfo = getjobChainHistoryInfoObject( "jobchain1", 20 ); // using the given job chain name and a given order_id // var jobChainHistoryInfo = getjobChainHistoryInfoObject( "jobchain1(order_id)", 20 ); // reporting some info on job runs report( jobChainHistoryInfo.getLastCompleted() ); report( jobChainHistoryInfo.getRunning() ); report( jobChainHistoryInfo.getLastCompletedSuccessful() ); report( jobChainHistoryInfo.getLastCompletedWithError() ); // report on currently running job report( jobChainHistoryInfo.getLastExecution() ); spooler_log.info("isStartedToday: " + jobChainHistoryInfo.isStartedToday()); spooler_log.info("isStartedTodayCompletedSuccessful: " + jobChainHistoryInfo.isStartedTodayCompletedSuccessful()); spooler_log.info("isStartedTodayCompletedWithError: " + jobChainHistoryInfo.isStartedTodayCompletedWithError()); spooler_log.info("isStartedTodayCompleted: " + jobChainHistoryInfo.isStartedTodayCompleted()); spooler_log.info("isCompletedToday: " + jobChainHistoryInfo.isCompletedToday()); spooler_log.info("isCompletedTodaySuccessful: " + jobChainHistoryInfo.isCompletedTodaySuccessful()); spooler_log.info("isCompletedTodayWithError: " + jobChainHistoryInfo.isCompletedTodayWithError()); spooler_log.info("endedAfter: " + jobChainHistoryInfo.endedAfter("03:00:00")); spooler_log.info("endedWithErrorAfter: " + jobChainHistoryInfo.endedWithErrorAfter("03:00:00")); spooler_log.info("endedSuccessfulAfter: " + jobChainHistoryInfo.endedSuccessfulAfter("03:00:00")); spooler_log.info("startedAfter: " + jobChainHistoryInfo.startedAfter("03:00:00")); spooler_log.info("startedWithErrorAfter: " + jobChainHistoryInfo.startedWithErrorAfter("03:00:00")); spooler_log.info("startedSuccessfulAfter: " + jobChainHistoryInfo.startedSuccessfulAfter("03:00:00")); spooler_log.info("isStartedToday:" + jobChainHistoryInfo.queryHistory("isStartedToday")); spooler_log.info("isStartedTodayCompletedSuccessful:" + jobChainHistoryInfo.queryHistory("isStartedTodayCompletedSuccessful")); spooler_log.info("isStartedTodayCompletedWithError:" + jobChainHistoryInfo.queryHistory("isStartedTodayCompletedWithError")); spooler_log.info("isStartedTodayCompleted:" + jobChainHistoryInfo.queryHistory("isStartedTodayCompleted")); spooler_log.info("isCompletedToday:" + jobChainHistoryInfo.queryHistory("isCompletedToday")); spooler_log.info("isCompletedTodaySuccessfully:" + jobChainHistoryInfo.queryHistory("isCompletedTodaySuccessful")); spooler_log.info("isCompletedTodayWithError:" + jobChainHistoryInfo.queryHistory("isCompletedTodayWithError ")); //since 1.10.2 1.9.8 also possible spooler_log.info("isCompletedAfter:" + jobChainHistoryInfo.queryHistory("isCompletedAfter(-1:10:48:33)")); spooler_log.info("isCompletedWithErrorAfter:" + jobChainHistoryInfo.queryHistory("isCompletedWithErrorAfter(03:00:00)")); spooler_log.info("isCompletedSuccessfulAfter:" + jobChainHistoryInfo.queryHistory("isCompletedSuccessfulAfter(03:00:00)")); spooler_log.info("isStartedAfter:" + jobChainHistoryInfo.queryHistory("isStartedAfter(-1:10:48:33)")); spooler_log.info("isStartedWithErrorAfter:" + jobChainHistoryInfo.queryHistory("isStartedWithErrorAfter(03:00:00)")); spooler_log.info("isStartedSuccessfulAfter:" + jobChainHistoryInfo.queryHistory("isStartedSuccessfulAfter(03:00:00)")); // example how to convert Date fields (start date) if ( jobChainHistoryInfo.getLastCompletedSuccessful().found ) { var d = jobChainHistoryInfo.getLastCompletedSuccessful().start; if (d != null) { spooler_log.info ("------->" + d ); spooler_log.info("-------------> d.toString(): " + lastRunCompleted); spooler_log.info("-------------> with format: " + d.format(java.time.format.DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss"))); } } spooler_log.info ( "check if the job chain started on the previous day before a specific point in time" ); var jobChainHistoryInfo = getjobChainHistoryInfoObject( "jobchain1", "", "-1:10:43:56" ); spooler_log.info ( "completedBefore -1:10:43:56: " + jobChainHistoryInfo.isCompletedBefore()); spooler_log.info ( "completedWithErrorBefore -1:10:43:56: " + jobChainHistoryInfo.isCompletedWithErrorBefore() ); spooler_log.info ( "completedSuccessfulBefore -1:10:43:56: " + jobChainHistoryInfo.isCompletedSuccessfulBefore() ); //since 1.10.2 1.9.8 also possible spooler_log.info ( "completedBefore -1:10:43:56: " + jobChainHistoryInfo.queryHistory("isCompletedBefore")); spooler_log.info ( "completedWithErrorBefore -1:10:43:56: " + jobChainHistoryInfo.queryHistory("isCompletedWithErrorBefore")); spooler_log.info ( "completedSuccessfulBefore -1:10:43:56: " + jobChainHistoryInfo.queryHistory("isCompletedSuccessfulBefore")); return false; } function getjobChainHistoryInfoObject(jobchain, limit, timelimit) { var jobChainHistory = new Packages.com.sos.jitl.checkrunhistory.JobChainHistory( spooler.delegate ); if ((jobchain === undefined) || (jobchain === "")) { jobchain = spooler_task.order.job_chain.name; } if (limit === undefined || limit === "") { limit = "100"; } if (timelimit === undefined) { timelimit = ""; } var jobChainHistoryInfo = jobChainHistory.getJobChainInfo( jobchain, limit, timelimit ); return jobChainHistoryInfo; } function report( reportItem ) { spooler_log.info( "_____________________________" ); if (reportItem.found) { spooler_log.info( "Name:" + reportItem.name ); spooler_log.info( "id: " + reportItem.id ); spooler_log.info( "Job chain name: " + reportItem.jobChainName ); spooler_log.info( "Position: " + reportItem.position ); spooler_log.info( "Start Time: " + reportItem.start ); spooler_log.info( "End Time: " + reportItem.end ); spooler_log.info( "Duration: " + reportItem.duration ); spooler_log.info( "Error: " + reportItem.error ); } else { spooler_log.info( "Name: " + reportItem.name + " not found" ); } }