Scheduled Job in Jira 8

Hi everyone,
We are trying to make a job-config plugin.
We implemented the Interface JobRunner like this
import javax.inject.Named;
import java.util.Map;

@Named(“myJobRunner”)
public class MyJobRunner implements JobRunner {
@Override
public JobRunnerResponse runJob(JobRunnerRequest request) {
System.out.println(“pppp”);
return null;
}

}
and the atlassian-plugin.xml is confgured like this:




and the pom.xml has this properties:
<jira.version>8.5.3</jira.version>
<amps.version>8.0.2</amps.version>

But this part of the add-on isn’t enable and the log doesn’t give us any information.
Can someone please help us =)

Hi Folino,
I’m trying to build a scheduled job as you in Jira 8. Did you solve your issues?
I don’t find any updated guide on how to do it, can you help me.

Hi Luca,
I achieved to make the scheduler first implements the class JobRunner as

@Named("myJob")
public class MyJob implements JobRunner

Then we implemented another class call LifecycleAware and imported do something like that:

@ExportAsService({LifecycleAware.class})
@Component
@Scanned
@Named("Schedule")
public class Schedule implements LifecycleAware {

    @JiraImport
    private SchedulerService schedulerService;


    private MyJob myJob;

    public Schedule(SchedulerService schedulerService,MyJob myJob){
        this.schedulerService = schedulerService;
        this.myJob = myJob;

    }


    @Override
    public void onStart() {
        schedulerService.registerJobRunner(JobRunnerKey.of("myJob"),myJob);
        try {
            //schedulerService.scheduleJob(JobId.of("jobRun"),JobConfig.forJobRunnerKey(JobRunnerKey.of("jobRun")));
            //JobConfig jobConfig = JobConfig.forJobRunnerKey(JobRunnerKey.of("jobRun")).withSchedule(Schedule.forCronExpression("0 5 * * * ?"));

            JobConfig jobConfig = JobConfig.forJobRunnerKey(JobRunnerKey.of("myJob")).withSchedule(Schedule.forCronExpression("0 0 5  * * ?"));
            schedulerService.scheduleJob(JobId.of("myJob"),jobConfig);
            
        } catch (SchedulerServiceException e) {
            e.printStackTrace();
        }
    }

Substantially, you need to call the key of the class JobRunner in the LifecycleAware onStart methods.

1 Like

Thank you very much.
I started to build my job as a service because I find it more useful to have it configurable on the admin page.

Thanks anyway for your precious information.

Best regards,
Luca