Dear All,
I am developing JIRA plugin for my internal operations. Part of the plugin has to trigger some task in every one/two minutes. So I have followed the following document
below is my atlassian-plugin.xml
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="myPlugin"/>
<!-- add our web resources -->
<web-resource key="myPlugin-resources" name="myPlugin Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="myPlugin.css" location="/css/myPlugin.css"/>
<resource type="download" name="myPlugin.js" location="/js/myPlugin.js"/>
<resource type="download" name="images/" location="/images"/>
<context>myPlugin</context>
</web-resource>
<job-config name="Test Job" key="testJobSchedule">
<job key="testJobRunner" perClusterJob="true" />
<schedule cron-expression="0 */2 * ? * *" jitterSecs="10"/>
<managed editable="true" keepingHistory="true" canRunAdhoc="true" canDisable="true"/>
</job-config>
</atlassian-plugin>
Java Code
package com.summa.work.impl;
import java.util.Date;
import com.atlassian.scheduler.JobRunner;
import com.atlassian.scheduler.JobRunnerRequest;
import com.atlassian.scheduler.JobRunnerResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import javax.inject.Named;
@Named
public class TestJobRunner implements JobRunner{
private static final Logger log = LoggerFactory.getLogger(TestJobRunner.class);
@Nullable
@Override
public JobRunnerResponse runJob(JobRunnerRequest jobRunnerRequest) {
System.out.println("Running the job at "+(new Date()).toString());
log.error("Running the job at "+(new Date()).toString());
return JobRunnerResponse.success("Job finished successfully.");
}
}
atlassian-jira.log
2019-09-12 00:11:07,008 UpmAsynchronousTaskManager:thread-2 DEBUG Eswaran 1253x256x1 xrsyqh 192.168.5.40 /rest/plugins/1.0/installed-marketplace [c.a.plugin.manager.DefaultPluginManager] Plugin module 'Test Job' is explicitly disabled (or so by default), so not re-enabling.
If I install the plugin, The Job Scheduler module alone not enabled.
Did I miss anything? How to enable the Job-Config module?
Please help me...
Thanks in advance...
Hi @Eswaran R
Check in the logs whilst the application is starting up the reason for that module to become disabled (if you are using Atlassian SDK to build your plugin and run the application), now if you are installing your plugin on a standalone instance, then review the logs during the installation process.
Apart from that, you should have:
@ExportAsService({LifecycleAware.class})
@Component
public class YourSchedulerImpl implements LifecycleAware, NotificationScheduler {
...
private final SchedulerService schedulerService;
...
@Inject
public YourSchedulerImpl(@ComponentImport final SchedulerService schedulerService,...)
With this, you would be able to:
# register your job
schedulerService.registerJobRunner(
# get all jobs you have created
schedulerService.getJobsByJobRunnerKey(
# unschedule obsolete jobs
schedulerService.unscheduleJob(
# schedule your job
schedulerService.scheduleJob(
With that in place, then you can call your implementation of JobRunner from YourSchedulerImpl.
The above will also handle DataCenter schedule events.
Kind regards,
Rafael
Thank you so much for your prompt response. You saved my time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.