This page lists event trigger scripts to be used in conjunction with workflow triggers. These scripts were taken straight from the public JIRA site. Please note that some scripts may be snippets and probably WILL need modification to work properly for your situation. Treat these as templates that you can modify from.
This script will determine if a secondary workflow has ran on a buildlife (with a success status). If it has, it will not trigger the workflow again.
Script Notes:
import com.urbancode.anthill3.domain.workflow.*; import com.urbancode.anthill3.domain.buildlife.*; import com.urbancode.anthill3.runtime.scripting.helpers.*; BuildLife bl = BuildLifeLookup.mostRecentSuccessForProjectAndWorkflowName(project, "Build Workflow"); if (bl == null){ return null; } WorkflowCase[] wc = WorkflowCaseFactory.getInstance().restoreArrayForBuildLife(bl); String msw = "Deploy Workflow"; //check to see that the secondary workflow ran, and was a success. for(int i = 0; i<wc.length; i++){ if(wc[i].getName().equals(msw)){ if(wc[i].isSuccess()){ return null; }//end if }//end if }//end for return bl;
This script applies to build lives created by the "Run" workflow of the project.
import com.urbancode.anthill3.domain.workflow.*; buildLife = BuildLifeLookup.mostRecentSuccessForProjectAndWorkflowName(project, "Run"); if (buildLife != null) { workflows = WorkflowCaseFactory.getInstance().restoreArrayForBuildLife(buildLife); for (int w=0; w<workflows.length; w++) { if (workflow.equals(workflows[w].getWorkflow())) { System.out.println("Workflow found, not running secondary workflow"); buildLife = null; break; } } } return buildLife;
In 3.5 and later you can use:
buildLife = BuildLifeLookup.mostRecentSuccessForProjectAndWorkflowName(project, "Run"); if (buildLife != null) { if (BuildLifeLookup.hasExecutedSecondaryWorkflow(buildLife, workflow)) { buildLife = null; } } return buildLife;