Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,062
Community Members
 
Community Events
176
Community Groups

Scheduler with Job-Config module is not enabled in JIRA plugin

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

Job-Config

 

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.

test job.jpg

Did I miss anything?  How to enable the Job-Config module?

Please help me...

Thanks in advance...

 

 

 

1 answer

1 accepted

1 vote
Answer accepted

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

Hi @Rafael Pinto Sperafico ,

Thank you so much for your prompt response. You saved my time.

Suggest an answer

Log in or Sign up to answer