public abstract class Trigger<J extends Item> extends Object implements Describable<Trigger<?>>, ExtensionPoint
Build
.
To register a custom Trigger
from a plugin,
put Extension
on your TriggerDescriptor
class.
Modifier and Type | Class and Description |
---|---|
static class |
Trigger.Cron
Runs every minute to check
TimerTrigger and schedules build. |
ExtensionPoint.LegacyInstancesAreScopedToHudson
Modifier and Type | Field and Description |
---|---|
protected J |
job |
protected String |
spec |
protected CronTabList |
tabs |
static Timer |
timer
Deprecated.
Use
Timer.get() instead. |
Modifier | Constructor and Description |
---|---|
protected |
Trigger()
Creates a new
Trigger without using cron. |
protected |
Trigger(String cronTabSpec)
|
Modifier and Type | Method and Description |
---|---|
static DescriptorExtensionList<Trigger<?>,TriggerDescriptor> |
all()
Returns all the registered
Trigger descriptors. |
static void |
checkTriggers(Calendar cal) |
static List<TriggerDescriptor> |
for_(Item i)
Returns a subset of
TriggerDescriptor s 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()
Action s to be displayed in the job page. |
String |
getSpec()
Gets the crontab specification.
|
protected Object |
readResolve() |
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. |
protected final String spec
protected transient CronTabList tabs
@CheckForNull protected transient J extends Item job
@Deprecated @CheckForNull public static Timer timer
Timer.get()
instead.Jenkins
, but value kept here for compatibility.
If plugins want to run periodic jobs, they should implement PeriodicWork
.protected Trigger(@Nonnull String cronTabSpec) throws antlr.ANTLRException
Trigger
that gets run
periodically. This is useful when your trigger does
some polling work.antlr.ANTLRException
protected Trigger()
Trigger
without using cron.public void start(J project, boolean newInstance)
Trigger
is loaded into memory and started.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 the Project
(generally if the project is being created or configured).
False if this is invoked for a Project
loaded from disk.Items.currentlyUpdatingByXml()
public void run()
Trigger(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.
public void stop()
@Deprecated public Action getProjectAction()
getProjectActions()
instead.public Collection<? extends Action> getProjectActions()
Action
s to be displayed in the job page.public TriggerDescriptor getDescriptor()
Describable
Descriptor
is a singleton for every concrete Describable
implementation, so if a.getClass() == b.getClass()
then by default
a.getDescriptor() == b.getDescriptor()
as well.
(In rare cases a single implementation class may be used for instances with distinct descriptors.)
getDescriptor
in interface Describable<Trigger<?>>
public final String getSpec()
protected Object readResolve() throws ObjectStreamException
ObjectStreamException
public static void checkTriggers(Calendar cal)
public static DescriptorExtensionList<Trigger<?>,TriggerDescriptor> all()
Trigger
descriptors.public static List<TriggerDescriptor> for_(Item i)
TriggerDescriptor
s that applys to the given item.Copyright © 2004–2018. All rights reserved.