[Index]

scheduling:trigger


A trigger runs it's job when the job being triggered on enters the state specified.

Once the trigger's job runs the trigger will reflect the state of the it's job. The trigger will continue to reflect it's job's state until it is reset.

Subsequent state changes in the triggering job are ignored until the trigger is reset and re-run.

If the triggering job is destroyed, because it is deleted or on a remote server the trigger will enter an exception state.


Property Summary

cancelWhen A state condition that will cause the trigger to cancel.
job The job to run when the trigger fires.
name A name, can be any text.
newOnly Fire trigger on new events only.
on The job the trigger will trigger on.
state The state condition which will cause the trigger to fire.

Example Summary

Example 1 A simple trigger.
Example 2 A trigger that runs once two other jobs have completed.
Example 3 Cancelling a trigger.
Example 4 Examples Elsewhere.

Property Detail

cancelWhen

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to not cancelling.

A state condition that will cause the trigger to cancel.

job

Configured ByELEMENT
AccessWRITE_ONLY
RequiredYes.

The job to run when the trigger fires.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

newOnly

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to false.

Fire trigger on new events only. If set the time on the event will be compared with the last that this trigger received and only a new event will cause the trigger to fire.

on

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredYes.

The job the trigger will trigger on.

state

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to COMPLETE.

The state condition which will cause the trigger to fire. See the Oddjob User guide for a full list of state conditions.


Examples

Example 1

A simple trigger.

<oddjob id="this">
    <job>
        <sequential name="Trigger Example">
            <jobs>
                <scheduling:trigger name="Alert Trigger" on="${important}" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
                    <job>
                        <echo name="Alert">Important job has completed!</echo>
                    </job>
                </scheduling:trigger>
                <folder name="A Folder of Jobs">
                    <jobs>
                        <echo id="important" name="Run Me">I'm important</echo>
                    </jobs>
                </folder>
            </jobs>
        </sequential>
    </job>
</oddjob>

Example 2

A trigger that runs once two other jobs have completed.

<oddjob xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling" xmlns:state="http://rgordon.co.uk/oddjob/state">
    <job>
        <sequential name="Trigger on Two Things">
            <jobs>
                <scheduling:trigger id="trigger" on="${watch-both}">
                    <job>
                        <echo id="notify" name="Triggered Job">You ran two things!</echo>
                    </job>
                </scheduling:trigger>
                <state:and id="watch-both" name="Watch Two Jobs">
                    <jobs>
                        <state:mirror job="${thing1}" name="Mirror Job 1"/>
                        <state:mirror job="${thing2}" name="Mirror Job 2"/>
                    </jobs>
                </state:and>
                <folder name="A Folder of Jobs">
                    <jobs>
                        <echo id="thing1" name="Run me!">Thank you</echo>
                        <echo id="thing2" name="Run me!">Thank you</echo>
                    </jobs>
                </folder>
            </jobs>
        </sequential>
    </job>
</oddjob>

Example 3

Cancelling a trigger.

<oddjob id="this" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
    <job>
        <sequential name="Trigger Example">
            <jobs>
                <scheduling:trigger id="trigger" name="Alert Trigger" on="${our-job}" state="FAILURE" cancelWhen="FINISHED">
                    <job>
                        <echo name="Alert" id="triggered-job">That job shouldn't fail!</echo>
                    </job>
                </scheduling:trigger>
                <folder name="A Folder of Jobs">
                    <jobs>
                        <echo id="our-job" name="Run Me">I won't fail</echo>
                    </jobs>
                </folder>
            </jobs>
        </sequential>
    </job>
</oddjob>

Example 4

Examples Elsewhere.


(c) Rob Gordon 2005 - 2014