Hello,
I wanted to create a Jira Event Listener with this Tutorial (https://developer.atlassian.com/server/jira/platform/writing-jira-event-listeners-with-the-atlassian-event-library/), but it is outdated and the listener won't work.
I found some posts with the same topic, but nothing helps me to get the listener working. I always create some errors, because there's nowhere a step by step instruction how to do it.
Could you please help me in saying what I have to change from the above linked tutorial to get it working in Jira 7+? Or do you have a downloadable source that I can use and that is working?
I know that all component-tags must disappear in the "atlassian-plugin.xml".
But how should the "IssueCreatedResolvedListener.java" file look like? And all the files beneath that. The pom.xml and stuff?
My last try with the "IssueCreatedResolvedListener.java" was this one:
package com.example.tutorial.plugins;
import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
//import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import com.atlassian.sal.api.lifecycle.LifecycleAware;
//import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
/**
* Simple JIRA listener using the atlassian-event library and demonstrating
* plugin lifecycle integration.
*/
//@ExportAsService
@Component
//@Named("IssueCreatedResolvedListener")
public class IssueCreatedResolvedListener implements InitializingBean, DisposableBean, LifecycleAware {
private static final Logger log = LoggerFactory.getLogger(IssueCreatedResolvedListener.class);
private final EventPublisher eventPublisher;
/**
* Constructor.
* @param eventPublisher injected {@code EventPublisher} implementation.
*/
public IssueCreatedResolvedListener(EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
/**
* Called when the plugin has been enabled.
* @throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
// register ourselves with the EventPublisher
eventPublisher.register(this);
}
/**
* Called when the plugin is being disabled or removed.
* @throws Exception
*/
@Override
public void destroy() throws Exception {
// unregister ourselves with the EventPublisher
eventPublisher.unregister(this);
}
/**
* Receives any {@code IssueEvent}s sent by JIRA.
* @param issueEvent the IssueEvent passed to us
*/
@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
Long eventTypeId = issueEvent.getEventTypeId();
Issue issue = issueEvent.getIssue();
// if it's an event we're interested in, log it
if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
log.info("Issue {} has been created at {}.", issue.getKey(), issue.getCreated());
} else if (eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)) {
log.info("Issue {} has been resolved at {}.", issue.getKey(), issue.getResolutionDate());
} else if (eventTypeId.equals(EventType.ISSUE_CLOSED_ID)) {
log.info("Issue {} has been closed at {}.", issue.getKey(), issue.getUpdated());
}
}
@Override
public void onStart() {
// TODO Auto-generated method stub
}
@Override
public void onStop() {
// TODO Auto-generated method stub
}
}
But it is not working.
Thank you very much. I hope that you can help me out a bit. I'm totally confused what to do here...
Best regards,
Hauke
I don't know exactly if this is working, because it is 1 year ago and I stopped using a listener for my needs, now I override the CreateWorklog Class.
But I think this was working Listener code:
XXXIssueEventListener:
package com.example.tutorial.plugins;
//import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
//import com.atlassian.plugin.spring.scanner.annotation.imports.JiraImport;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.DisposableBean;
//import org.springframework.beans.factory.InitializingBean;
//import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.atlassian.jira.event.issue.IssueEventListener;
@Component
public class XXXIssueEventListener implements IssueEventListener {
private static Logger log;
public XXXIssueEventListener() {
log = LoggerFactory.getLogger(XXXIssueEventListener.class);
}
@Override
public String[] getAcceptedParams() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getDescription() {
// TODO Auto-generated method stub
return null;
}
@Override
public void init(Map<String, String> arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean isInternal() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isUnique() {
// TODO Auto-generated method stub
return false;
}
@Override
public void customEvent(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueAssigned(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueClosed(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueCommented(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueCreated(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueDeleted(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueGenericEvent(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueMoved(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueReopened(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueResolved(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueStarted(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueStopped(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueUpdated(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void issueWorkLogged(IssueEvent arg0) {
// TODO Auto-generated method stub
this.workflowEvent(arg0);
}
@Override
public void workflowEvent(IssueEvent issueEvent) {
if (issueEvent.getEventTypeId() == EventType.ISSUE_WORKLOGGED_ID) {
Issue issue = issueEvent.getIssue();
System.out.println(issueEvent.getWorklog().getTimeSpent() / 60 );
System.out.println("Working hours updated!");
System.out.println("Issue: " + issue.getKey());
System.out.println("Bearbeitet von: " + issue.getReporter());
System.out.println("Datum: " + issue.getUpdated());
System.out.println("Stunden: " + issue.getTimeSpent());
log.info("Issue {} has been updated at {}.", issue.getKey(), issue.getCreated());
}
}
}
IssueCreatedResolvedListener:
package com.example.tutorial.plugins;
import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
import com.atlassian.plugin.spring.scanner.annotation.imports.JiraImport;
//import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//import com.atlassian.jira.event.issue.IssueEventListener;
@Component
public class IssueCreatedResolvedListener implements InitializingBean, DisposableBean {
private static final Logger log = LoggerFactory.getLogger(IssueCreatedResolvedListener.class);
@JiraImport
private final EventPublisher eventPublisher;
@Autowired
public IssueCreatedResolvedListener(EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
/**
* Called when the plugin has been enabled.
* @throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
log.info("Enabling plugin");
eventPublisher.register(this);
}
/**
* Called when the plugin is being disabled or removed.
* @throws Exception
*/
@Override
public void destroy() throws Exception {
log.info("Disabling plugin");
eventPublisher.unregister(this);
}
@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
Long eventTypeId = issueEvent.getEventTypeId();
Issue issue = issueEvent.getIssue();
if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
System.out.println("TEST created");
log.info("Issue {} has been created at {}.", issue.getKey(), issue.getCreated());
} else if (eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)) {
System.out.println("TEST ISSUE_RESOLVED_ID");
log.info("Issue {} has been resolved at {}.", issue.getKey(), issue.getResolutionDate());
} else if (eventTypeId.equals(EventType.ISSUE_CLOSED_ID)) {
System.out.println("TEST created");
log.info("Issue {} has been closed at {}.", issue.getKey(), issue.getUpdated());
} else if (eventTypeId.equals(EventType.ISSUE_UPDATED_ID)) {
System.out.println("TEST created");
log.info("Issue {} has been closed at {}.", issue.getKey(), issue.getUpdated());
}
}
}
And this is the pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.tutorial.plugins</groupId>
<artifactId>new-listener-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<organization>
<name>XXX</name>
<url>http://XXX.XXX/</url>
</organization>
<name>new-listener-plugin</name>
<description>This should listen...</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.6.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<log4jProperties>src/aps/log4j.properties</log4jProperties>
<applications>
<application>
<applicationKey>jira-software</applicationKey>
<version>${jira.version}</version>
</application>
</applications>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!--
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
-->
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<!-- OWN -->
<!-- make AMPS faster -->
<enableDevToolbox>false</enableDevToolbox>
<enablePde>false</enablePde>
<skipRestDocGeneration>true</skipRestDocGeneration>
<allowGoogleTracking>false</allowGoogleTracking>
<skipManifestValidation>true</skipManifestValidation>
<extractDependencies>false</extractDependencies>
<!-- OWN -->
<pluginArtifact>
<groupId>com.atlassian.labs.plugins</groupId>
<artifactId>quickreload</artifactId>
<version>${quick.reload.version}</version>
</pluginArtifact>
<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>com.example.tutorial.plugins.api,</Export-Package>
<!-- Add package import here -->
<Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", *</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
<atlassian.dev.mode>true</atlassian.dev.mode>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jira.version>7.7.1</jira.version>
<amps.version>6.3.15</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project
In atlassian-plugin.xml there was nothing special needed I think.
I don't know if this helps, but good luck :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just found another version of IssueEventListener, it should be it bit newer. Good luck with it:
XXXIssueEventListener.java:
package com.XXX.jira;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.atlassian.jira.event.issue.IssueEventListener;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
@Component
public class XXXIssueEventListener implements IssueEventListener {
private static Logger log;
private final CustomFieldManager customFieldManager;
public XXXIssueEventListener() {
log = LoggerFactory.getLogger(XXXIssueEventListener.class);
this.customFieldManager = ComponentAccessor.getCustomFieldManager();
}
@Override
public void workflowEvent(IssueEvent issueEvent) {
if (issueEvent.getEventTypeId() == EventType.ISSUE_WORKLOGGED_ID) {
Issue issue = issueEvent.getIssue();
CustomField customField = customFieldManager.getCustomFieldObject("customfield_10000");
// "customfield_10000" = "PSP-Element", siehe http://localhost:2990/jira/rest/api/2/field
Object customFieldValue = customField.getValue(issue);
System.out.println();
System.out.println("Working hours updated!");
System.out.println("Issue Name: " + issue);
System.out.println("Issue ID: " + issue.getId());
System.out.println("Bearbeitet von: " + issueEvent.getWorklog().getUpdateAuthorObject());
System.out.println("Datum: " + issueEvent.getWorklog().getUpdated());
System.out.println("Gebuchte Zeit (min): " + issueEvent.getWorklog().getTimeSpent() / 60);
System.out.println("Kommentar: " + issueEvent.getWorklog().getComment());
System.out.println("Custom Field: " + customFieldValue);
log.info("Issue {} has been updated at {}.", issue.getKey(), issue.getCreated());
}
}
@Override
public String[] getAcceptedParams() {
return null;
}
@Override
public String getDescription() {
return null;
}
@Override
public void init(Map<String, String> arg0) {
}
@Override
public boolean isInternal() {
return false;
}
@Override
public boolean isUnique() {
return false;
}
@Override
public void customEvent(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueAssigned(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueClosed(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueCommented(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueCreated(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueDeleted(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueGenericEvent(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueMoved(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueReopened(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueResolved(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueStarted(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueStopped(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueUpdated(IssueEvent arg0) {
this.workflowEvent(arg0);
}
@Override
public void issueWorkLogged(IssueEvent arg0) {
this.workflowEvent(arg0);
}
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.XXX.jira</groupId>
<artifactId>listenerPlugin</artifactId>
<version>1.0</version>
<organization>
<name>XXX</name>
<url>http://www.XXX.com/</url>
</organization>
<name>listenerPlugin</name>
<description>This is the com.XXX.jira:listenerPlugin plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>
<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!--
<dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>2.5.6.SEC02</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.0.5.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.labs.plugins</groupId>
<artifactId>quickreload</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>atlassian-jira-webapp</artifactId>
<version>7.7.1</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!--
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
-->
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<!-- make AMPS faster -->
<enableFastdev>false</enableFastdev>
<enableDevToolbox>false</enableDevToolbox>
<enablePde>false</enablePde>
<skipRestDocGeneration>true</skipRestDocGeneration>
<allowGoogleTracking>false</allowGoogleTracking>
<skipManifestValidation>true</skipManifestValidation>
<extractDependencies>false</extractDependencies>
<pluginArtifact>
<groupId>com.atlassian.labs.plugins</groupId>
<artifactId>quickreload</artifactId>
<!--<version>${quick.reload.version}</version>-->
<version>2.0.1</version>
</pluginArtifact>
<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>
com.XXX.jira.api,
</Export-Package>
<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*;version="0";resolution:=optional
</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>atlassian</id>
<name>Atlassian Repository</name>
<url>https://maven.atlassian.com/content/groups/public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://m2proxy.atlassian.com/repository/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<jira.version>7.7.1</jira.version>
<amps.version>6.3.15</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.local.repo>C:\Applications\Atlassian\atlassian-plugin-sdk-6.3.10\repository</maven.local.repo>
<confluence.version>3.3</confluence.version>
<confluence.data.version>3.1</confluence.data.version>
<quick.reload.version>2.0.1</quick.reload.version>
</properties>
</project>
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.
I tried it with this instructions using SAL: https://community.developer.atlassian.com/t/how-to-find-out-org-springframework-version-used-by-upm/1907/2
Now my Java File looks like this:
package com.mytest.listenerPlugin;
import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.issue.Issue;
import com.atlassian.sal.api.lifecycle.LifecycleAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IssueCreatedResolvedListener implements LifecycleAware
{
private final EventPublisher eventPublisher;
private static final Logger log = LoggerFactory.getLogger(IssueCreatedResolvedListener.class);
public IssueCreatedResolvedListener(final EventPublisher eventPublisher)
{
this.eventPublisher = eventPublisher;
}
@Override
public void onStart()
{
eventPublisher.register(this);
}
@Override
public void onStop()
{
eventPublisher.unregister(this);
}
@EventListener
public void someEventFunction(IssueEvent event)
{
Long eventTypeId = event.getEventTypeId();
Issue issue = event.getIssue();
if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
log.info("Issue {} has been created at {}.", issue.getKey(), issue.getCreated());
System.out.println("iiiiiiiiiiiiiiiiiinfo: ISSUE CREATED");
} else if (eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)) {
log.info("Issue {} has been resolved at {}.", issue.getKey(), issue.getResolutionDate());
System.out.println("iiiiiiiiiiiiiiiiiinfo: ISSUE RESOLVED");
} else if (eventTypeId.equals(EventType.ISSUE_CLOSED_ID)) {
log.info("Issue {} has been closed at {}.", issue.getKey(), issue.getUpdated());
System.out.println("iiiiiiiiiiiiiiiiiinfo: ISSUE CLOSED");
}
}
}
But nothing happens here...
I've done nothing in my atlassian-plugin.xml file. Do I have to do something there?
And in my pom.xml, all I did was adding this:
<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
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.