Class Trigger<J extends Item>

    • Field Detail

      • spec

        protected final String spec
      • job

        protected transient J extends Item job

        public static long CRON_THRESHOLD
        Used to be milliseconds, now is seconds since Jenkins 2.289.
      • timer

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

      • Trigger

        protected Trigger​(@NonNull
                          String cronTabSpec)
        Creates a new Trigger that gets run periodically. This is useful when your trigger does some polling work.
        cronTabSpec - the crontab entry to be parsed
        IllegalArgumentException - if the crontab entry cannot be parsed
      • Trigger

        protected Trigger()
        Creates a new Trigger without using cron.
    • Method Detail

      • start

        public void start​(J project,
                          boolean newInstance)
        Called when a 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.
        See Also:
      • 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.

        Maybe run even before start(hudson.model.Item, boolean), prepare for it.

      • 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.

      • getProjectActions

        public Collection<? extends Action> getProjectActions()
        Actions to be displayed in the job page.
        can be empty but never null
      • 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 by default a.getDescriptor() == b.getDescriptor() as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)

        Specified by:
        getDescriptor in interface Describable<J extends Item>
      • 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)