Have you ever thought of running scheduled tasks within JIRA? While services can run as scheduled tasks in JIRA 7, there might be scenarios where we want to do everything in code. We might want to remove the extra step of registering a service and the possibility of an admin deleting/editing/rescheduling the service.
Atlassian Scheduler API and the SchedulerService give us an easy way to write scheduled jobs in JIRA. In this recipe, we will write a simple scheduled task and see how to automatically register them.
Just like services, these scheduled tasks can also be part of a v2 plugin and can be uploaded using UPM.
Let us write a simple scheduled task that prints a line in the console. Perform the following steps:
Write a java class that implements the
com.atlassian.scheduler.JobRunner
interface.Register the new class as a component and make it an OSGI service using the
ExportAsService
andNamed
annotations, as shown here. This is equivalent to...