This article describes how to set and transition a state for a job, for example, resume a job where it failed last time.
For example, if a job has 10 steps, and steps 1 through 4 previously succeeded, then next time resume at step 5.
Create a Run Condition that locates appropriate step and checks its status.
Create a link to the previous run of the procedure.
A sample procedure is attached.
The sample contains a few dummy steps that use Run Condition defined in a property. For testing purposes, you can force one or more of these steps to fail by changing "
exit 0;" to "
exit 1;". Also there is an empty "jobToRestart" parameter to hold a job ID that will be re-run.
The procedure also has an "always run" step that creates a link called "Restart this job". If you click this link, the procedure will rerun itself, skipping the steps that succeeded or were already skipped in its previous run. If you click "Run again", the procedure will rerun all of the steps. The "Run Condition" will work in subprocedure steps as well.
One item that is not implemented here: If your procedure has parameters, they must be passed to the link.
Code for Run Condition:
Code for creating a link:
use strict; $| = 1; use ElectricCommander; my $ec = new ElectricCommander; # Build the URL for restarting the job my $url = 'runProcedure.php?'; $url .= 'runNow=1'; $url .= '&procedureName=$[/myJob/procedureName]'; $url .= '&projectName=$[/myJob/projectName]'; $url .= '&numParameters=1'; $url .= '¶meters1_name=jobToRestart'; $url .= '¶meters1_value=$[jobId]'; # Set the Link property print "URL is $url\n"; $ec->setProperty("/jobs/$[jobId]/report-urls/Restart This Job", $url);