Jira Issue Event Listener

Hello Community,

This is my first question in to the community. Will appreciate your precious help.
I wanted to develop an add-on for our Jira(v6.4.12) which will listen to the issue events e.g create,update,resolve,close etc and save them into a text or pdf file. I went through one tutorial given for Jira Issue Event Listener plugin, I created a jar and uploaded the same on our UAT but it is not logging any issues. Can anybody please help me on this as I am stucked at this issue since last 7 months.

Hi Bhushan. Do you use a development environment that allows for step-wise debugging? It would be helpful to put a breakpoint in your event listener to see if it is being invoked.

How are you producing the output? Would you please post the relevant code?

You might find my answer to another event-listener-related post helpful.

Hi David,

I am using Eclipse Neon 4.6.3 for java development and Atlassian SDK 6.2.14. As plugin development is Maven based and I am a beginner in Maven I honestly don’t know how to see output of a Maven project in eclipse console.
I went through the instructions given in below tutorial,
Jira Issue Event Listener
Then I built the project by using ‘Maven Build’ command. Created a jar of this project and added it on my UAT environment. It was uploaded successfully as an add-on and I enabled the plugin successfully on my UAT environment.
As mentioned in above tutorial I had added the last two lines of ‘log4j.properties’ file in my own log4j.properties file.
Now I tested the plugin by creating, updating ,resolving and closing some issues but nothing was logged in my jira logs.
Please check the code in the tutorial given and let me know where I am doing wrong.
Your help is appreciated. Thanks in advance :slight_smile:

You might want to look at the Logging settings in JIRA itself. There’s an administration page for that, where you can see the Java packages that are being logged.

Hi David,

If you have went through the tutorial code I want to know a thing or two.

  1. I want to create a text file on my server(where I am hosting my jira application) whenever there are changes made in the any issue like create,update,resolve and close.
  2. For every issue there should be a new text file to be created.
  3. I know how to do it in plain java but for jira and maven I am not able to understand how I can do this.

Your help is greatly appreciated.
Thank you
Bhushan :slight_smile:

I’ve learned something that explains why you are not getting any logging output in your UAT environment: the Atlassian SDK documentation, says:

“A plugin specific log4j.properties file does not get picked up using this method once you deploy your plugin to another stand alone server. It only works using atlas-run or atlas-debug.”

So that’s an answer to part of your question. It is possible to configure JIRA’s logging so that you would get logging output in your UAT environment; the question is this: does use of the logging framework make sense for you?

The SLF4J framework from the tutorial isn’t designed to produce separate files for each log entry. Maybe you should write directly to files using standard Java IO. To determine the location for your files, call com.atlassian.sal.api.ApplicationProperties#getHomeDirectory.

1 Like

Thanks a ton David for your precious help…
:slight_smile: :slight_smile:

Hi David,

Can you please help me on this?
I am trying to print ‘ChangeHistoryItems’ for a particular issue.
It picks the change and prints the values into my file.
But when I change fields like ‘Summary’,‘Description’ etc. it doesn’t print anything.It shows {} {} for getFroms() and getTos() rather than printing the text present.
Following is the code that I have written,

public void onIssueEvent(IssueEvent issueEvent) throws IOException {
Long eventTypeId = issueEvent.getEventTypeId();
Issue issue = issueEvent.getIssue();
ChangeHistoryManager chm = ComponentAccessor.getChangeHistoryManager();
List chi = chm.getAllChangeItems(issue);

	Writer writer = null;
	try {
		try {
			File file = new File("/data2/jboss/Jira Issue Logs/"+issue.getKey()+".txt");
			writer = new BufferedWriter(new FileWriter(file,true));

			// if it's an event we're interested in, log it
			if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
								"Issue Creation Details"+"\r\n"+
						"Issue Key       : "+issue.getKey() +"\r\n"+ 
						"Creation Date   : "+issue.getCreated() +"\r\n"+
						"Created By      : "+issue.getCreator()+"\r\n"+		
						"Summary         : "+issue.getSummary()+"\r\n"+
						"Project Name    : "+issue.getProjectObject()+"\r\n"+ 
						"Status          : "+issue.getStatusObject());
			} else if (eventTypeId.equals(EventType.ISSUE_UPDATED_ID)){
				ChangeHistoryItem chobj;
				for(int i=0;i<chi.size();i++)
					chobj = (ChangeHistoryItem)chi.get(i);
					writer.write(" "+"\r\n"+
					chobj.getUserKey()+"   "+chobj.getField()+"   "+chobj.getFroms().toString()+"   "+chobj.getTos().toString()

Please let me know what I am doing wrong and suggest the changes.
Thanks in advance :slight_smile:

You might try calling:

  • ChangeHistoryManager.getChangeHistories(Issue issue) or
  • ChangeHistoryManager.getChangeHistoriesSince(@Nonnull Issue issue, @Nonnull Date since).

Then call ChangeHistory.getChangeItems() on the result.


Thanks David it worked… :slight_smile: