Package hudson.triggers
Class Trigger<J extends Item>
java.lang.Object
hudson.triggers.Trigger<J>
- All Implemented Interfaces:
ExtensionPoint,Describable<Trigger<?>>
- Direct Known Subclasses:
ReverseBuildTrigger,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
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRuns every minute to checkTimerTriggerand schedules build.Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic longUsed to be milliseconds, now is seconds since Jenkins 2.289.protected Jprotected final Stringprotected CronTabListstatic TimerDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DescriptorExtensionList<Trigger<?>, TriggerDescriptor> all()Returns all the registeredTriggerdescriptors.static voidcheckTriggers(Calendar cal) static List<TriggerDescriptor> Returns a subset ofTriggerDescriptors that applies to the given item.Gets the descriptor for this instance.Deprecated.as of 1.341 UsegetProjectActions()instead.Collection<? extends Action> Actions to be displayed in the job page.final StringgetSpec()Gets the crontab specification.protected Objectvoidrun()Executes the triggered task.voidCalled when aTriggeris loaded into memory and started.voidstop()Called before aTriggeris removed.toString()
-
Field Details
-
spec
-
tabs
-
job
-
CRON_THRESHOLD
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.289") public static long CRON_THRESHOLDUsed to be milliseconds, now is seconds since Jenkins 2.289. -
timer
Deprecated.UseTimer.get()instead.This timer is available for all the components inside Hudson to schedule some work. Initialized and cleaned up byJenkins, but value kept here for compatibility. If plugins want to run periodic jobs, they should implementPeriodicWork.
-
-
Constructor Details
-
Trigger
Creates a newTriggerthat getsrunperiodically. This is useful when your trigger does some polling work.- Parameters:
cronTabSpec- the crontab entry to be parsed- Throws:
IllegalArgumentException- if the crontab entry cannot be parsed
-
Trigger
protected Trigger()Creates a newTriggerwithout using cron.
-
-
Method Details
-
start
Called when aTriggeris 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 may be a newly created trigger first attached to theProject(generally if the project is being created or configured). False if this is invoked for aProjectloaded from disk.- See Also:
-
run
public void run()Executes the triggered task. This method is invoked whenTrigger(String)is used to create an instance, and the crontab matches the current time.Maybe run even before
start(hudson.model.Item, boolean), prepare for it. -
stop
public void stop() -
getProjectAction
Deprecated.as of 1.341 UsegetProjectActions()instead. -
getProjectActions
Actions to be displayed in the job page.- Returns:
- can be empty but never null
- Since:
- 1.341
-
getDescriptor
Description copied from interface:DescribableGets the descriptor for this instance.Descriptoris a singleton for every concreteDescribableimplementation, so ifa.getClass() == b.getClass()then by defaulta.getDescriptor() == b.getDescriptor()as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)By default looks for a nested class (conventionally named
DescriptorImpl) implementingDescriptorand marked withExtension.- Specified by:
getDescriptorin interfaceDescribable<J extends Item>
-
getSpec
Gets the crontab specification. If you are not using cron service, just ignore it. -
readResolve
- Throws:
ObjectStreamException
-
toString
-
checkTriggers
-
all
Returns all the registeredTriggerdescriptors. -
for_
Returns a subset ofTriggerDescriptors that applies to the given item.
-
Timer.get()instead.