We are using below code for listning the events from jira but its not working . It was working fine with jira 5.2.4 but when jira is upgarded to 6.0 it stopped working.:
"deployFileStage" and "deployFileProd" are the events which we have configured in jira
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.event.issue.AbstractIssueEventListener; import com.atlassian.jira.event.issue.IssueEvent; import com.atlassian.jira.event.type.EventType; import com.atlassian.jira.event.type.EventTypeManager; import org.apache.log4j.Logger; public class DeployEventListener extends AbstractIssueEventListener { private static Logger LOG = Logger.getLogger(DeployEventListener.class); public DeployEventListener() { } public void customEvent(IssueEvent event) { // We are not able to get the event name String eventName = ComponentAccessor.getEventTypeManager().getEventType(event.getEventTypeId()).getName(); if(eventName.contains("deployFileStage")) { DeployManager.initiateDeployment(event, "stage"); } else if(eventName.contains("deployFileProd")) { DeployManager.initiateDeployment(event, "prod"); } } }
i suggest to delete and reconfigure listener so it may work!!
and also give prints inside your listener so you can debug that which part is not working!
and also you need to write like as follows
@EventListener public void onIssueEvent(IssueEvent issueEvent) { Long eventTypeId = issueEvent.getEventTypeId(); Issue issue = issueEvent.getIssue(); 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()); } }
and also i suggest to go through the document as above people suggested!!
Thanks Rambanam ... The error was with log file .. I put sysouts and it worked .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You might want to change the code to use the latest way of listening to events (https://developer.atlassian.com/display/JIRADEV/Writing+JIRA+Event+Listeners+with+the+atlassian-event+Library).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have changed the code as per the documentation but still its not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
package com.blah.blah.eventlisteners;
import com.atlassian.jira.component.*;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.type.EventTypeManager;
import com.blah.blah.commentutil.CommentsUtil;
import com.blah.blah.deploymanager.DeployManager;
import com.blah.blah.jira.commentutil.*;
import org.apache.log4j.Logger;
import com.atlassian.event.api.EventPublisher;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
public class DeployEventListener implements InitializingBean, DisposableBean {
private static Logger LOG = Logger.getLogger(DeployEventListener.class);
private final EventTypeManager eventTypeManager;
private final EventPublisher eventPublisher;
private final DeployManager deployManager;
public DeployEventListener(DeployManager deployManager, EventPublisher eventPublisher, EventTypeManager eventTypeManager){
this.deployManager = deployManager;
this.eventPublisher = eventPublisher;
this.eventTypeManager = eventTypeManager;
}
public void customEvent(IssueEvent event){
Long eventTypeId = event.getEventTypeId();
String eventName = eventTypeManager.getEventType(eventTypeId).getName();
if(eventName.contains("Stage_Deployment")){
DeployManager.initiateDeployment(event, "stage");
}
public void afterPropertiesSet()
throws Exception
{
eventPublisher.register(this);
}
public void destroy()
throws Exception
{
eventPublisher.unregister(this);
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
package com.blah.blah.eventlisteners; import com.atlassian.jira.component.*; import com.atlassian.jira.event.issue.AbstractIssueEventListener; import com.atlassian.jira.event.issue.IssueEvent; import com.atlassian.jira.event.type.EventTypeManager; import com.blah.blah.commentutil.CommentsUtil; import com.blah.blah.deploymanager.DeployManager; import com.blah.blah.jira.commentutil.*; import org.apache.log4j.Logger; import com.atlassian.event.api.EventPublisher; //import org.slf4j.Logger; //import org.slf4j.LoggerFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; public class DeployEventListener implements InitializingBean, DisposableBean { private static Logger LOG = Logger.getLogger(DeployEventListener.class); private final EventTypeManager eventTypeManager; private final EventPublisher eventPublisher; private final DeployManager deployManager; public DeployEventListener(DeployManager deployManager, EventPublisher eventPublisher, EventTypeManager eventTypeManager){ this.deployManager = deployManager; this.eventPublisher = eventPublisher; this.eventTypeManager = eventTypeManager; } public void customEvent(IssueEvent event){ Long eventTypeId = event.getEventTypeId(); String eventName = eventTypeManager.getEventType(eventTypeId).getName(); if(eventName.contains("Stage_Deployment")){ DeployManager.initiateDeployment(event, "stage"); } public void afterPropertiesSet() throws Exception { eventPublisher.register(this); } public void destroy() throws Exception { eventPublisher.unregister(this); } } }
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.
Forget your code for now, follow the tutorial that have now been suggested twice by two people :D you are trying to use the customEvent method, which isnt what the tutorial shows.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.
Register nowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.