hudson.triggers
Class Trigger<J extends Item>

java.lang.Object
  extended by hudson.triggers.Trigger<J>
All Implemented Interfaces:
ExtensionPoint, Describable<Trigger<?>>
Direct Known Subclasses:
SCMTrigger, TimerTrigger

public abstract class Trigger<J extends Item>
extends Object
implements Describable<Trigger<?>>, ExtensionPoint

Triggers a Build.

To register a custom Trigger from a plugin, put Extension on your TriggerDescriptor class.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class Trigger.Cron
          Runs every minute to check TimerTrigger and schedules build.
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
static Timer timer
          This timer is available for all the components inside Hudson to schedule some work.
 
Method Summary
static DescriptorExtensionList<Trigger<?>,TriggerDescriptor> all()
          Returns all the registered Trigger descriptors.
static void checkTriggers(Calendar cal)
           
 boolean equals(Object o)
           
static List<TriggerDescriptor> for_(Item i)
          Returns a subset of TriggerDescriptors that applys to the given item.
 TriggerDescriptor getDescriptor()
          Gets the descriptor for this instance.
 Action getProjectAction()
          Deprecated. as of 1.341 Use getProjectActions() instead.
 Collection<? extends Action> getProjectActions()
          Actions to be displayed in the job page.
 String getSpec()
          Gets the crontab specification.
 int hashCode()
           
static void init()
           
 void run()
          Executes the triggered task.
 void start(J project, boolean newInstance)
          Called when a Trigger is loaded into memory and started.
 void stop()
          Called before a Trigger is removed.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

public static Timer timer
This timer is available for all the components inside Hudson to schedule some work. Initialized and cleaned up by Hudson, but value kept here for compatibility. If plugins want to run periodic jobs, they should implement PeriodicWork.

Method Detail

start

public void start(J project,
                  boolean newInstance)
Called when a Trigger is loaded into memory and started.

Parameters:
project - given so that the persisted form of this object won't have to have a back pointer.
newInstance - True if this is a newly created trigger first attached to the Project. False if this is invoked for a Project loaded from disk.

run

public void run()
Executes the triggered task. This method is invoked when Trigger(String) is used to create an instance, and the crontab matches the current time.


stop

public void stop()
Called before a Trigger is removed. Under some circumstances, this may be invoked more than once for a given Trigger, so be prepared for that.

When the configuration is changed for a project, all triggers are removed once and then added back.


getProjectAction

public Action getProjectAction()
Deprecated. as of 1.341 Use getProjectActions() instead.

Returns an action object if this Trigger has an action to contribute to a Project.


getProjectActions

public Collection<? extends Action> getProjectActions()
Actions to be displayed in the job page.

Returns:
can be empty but never null
Since:
1.341

getDescriptor

public TriggerDescriptor getDescriptor()
Description copied from interface: Describable
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<Trigger<?>>

getSpec

public final String getSpec()
Gets the crontab specification. If you are not using cron service, just ignore it.


checkTriggers

public static void checkTriggers(Calendar cal)

init

@Initializer(after=JOB_LOADED)
public static void init()

all

public static DescriptorExtensionList<Trigger<?>,TriggerDescriptor> all()
Returns all the registered Trigger descriptors.


for_

public static List<TriggerDescriptor> for_(Item i)
Returns a subset of TriggerDescriptors that applys to the given item.


equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2004-2013 Hudson. All Rights Reserved.