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
Modifier and TypeClassDescriptionstatic class
Runs every minute to checkTimerTrigger
and schedules build.Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionstatic long
Used to be milliseconds, now is seconds since Jenkins 2.289.protected J
protected final String
protected CronTabList
static Timer
Deprecated. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DescriptorExtensionList<Trigger<?>,
TriggerDescriptor> all()
Returns all the registeredTrigger
descriptors.static void
checkTriggers
(Calendar cal) static List<TriggerDescriptor>
Returns a subset ofTriggerDescriptor
s that applies to the given item.Gets the descriptor for this instance.Deprecated.as of 1.341 UsegetProjectActions()
instead.Collection<? extends Action>
Action
s to be displayed in the job page.final String
getSpec()
Gets the crontab specification.protected Object
void
run()
Executes the triggered task.void
Called when aTrigger
is loaded into memory and started.void
stop()
Called before aTrigger
is 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 newTrigger
that getsrun
periodically. 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 newTrigger
without using cron.
-
-
Method Details
-
start
Called when aTrigger
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 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 aProject
loaded 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
Action
s to be displayed in the job page.- Returns:
- can be empty but never null
- Since:
- 1.341
-
getDescriptor
Description copied from interface:Describable
Gets the descriptor for this instance.Descriptor
is a singleton for every concreteDescribable
implementation, 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.)- Specified by:
getDescriptor
in 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 registeredTrigger
descriptors. -
for_
Returns a subset ofTriggerDescriptor
s that applies to the given item.
-
Timer.get()
instead.