Trigger module

Available:

From Confluence 2.2 to Confluence 5.9

Changed:

In Confluence 3.5 and later, the trigger element accepts an optional child element (managed), which defines the scheduled job's availability in Confluence's administration console.

Status:Deprecated in Confluence 5.10, use Job Config instead

Using Trigger plugin modules you can schedule when your Job Module are scheduled to run Confluence.

Trigger Plugin Module

The Trigger plugin module schedules Jobs within a plugin. Triggers are one of two types:

  • Cron – jobs are scheduled using cron syntax.
  • Simple – jobs are scheduled to repeat every X seconds.

Here is a sample atlassian-plugin.xml fragment containing a Job with its corresponding Trigger module using a cron-style expression (for reference, this expression will execute the job with key 'myJob' every minute):

1
2
3
4
5
6
7
8
9
10
11
12
<atlassian-plugin name="Sample Component" key="confluence.extra.component">
    ...
    <job key="myJob"
          name="My Job"
          class="com.example.myplugin.jobs.MyJob" />
    <trigger key="myTrigger" name="My Trigger">       
        <job key="myJob" />       
        <schedule cron-expression="0 * * * * ?" />     
        <managed editable="true" keepingHistory="true" canRunAdhoc="true" canDisable="true" />
    </trigger>
    ...
</atlassian-plugin>

The trigger element accepts the following attributes:

  • name – represents how this component will be referred to in the Confluence interface.
  • key – represents the internal system name for your Trigger.

The trigger element also accepts the following elements:

  • schedule – defines a cron expression in its cron-expression attribute. You can find more information about cron expressions on the Scheduled Jobs page (or the Cron Trigger tutorial on the Quartz website).
  • managed (Available only starting from in Confluence 3.5) – an optional element that defines the configuration of the job on the Scheduled Jobs administration page. If the managed element is omitted, then the job will not appear in the Scheduled Jobs administration page. This element takes the following attributes each of which takes the values of either true or false:
    NOTE: If any of these attributes are omitted, their values are assumed to be false. editable – If true, the job's schedule can be edited. keepingHistory – If true, the job's history persists and survives server restarts. If false, the job history is stored only in memory and will be lost upon the next server restart. canRunAdhoc – If true, the job can be executed manually on the Scheduled Job administration screen. canDisable – If true, the job can be enabled/disabled on the Scheduled Jobs administration screen.

Here is another example, this time using a simple trigger that repeats every 3600000 milliseconds (1 hour) and will only repeat 5 times:

1
2
3
4
5
6
...
    <trigger key="myTrigger" name="My Trigger">
        <job key="myJob" />
        <schedule repeat-interval="3600000" repeat-count="5" />
     </trigger>    
...