How to limit notifications for automation actions
Often it is desirable to have automation perform actions that do not cause notifications to be sent that normally would be. Some examples are:
Changing an issue multiple times in a sequence of updates
Updating a field on a regular basis
Unfortunately, the notification schemes don't have an option regarding the originator of the request. Here is what can be done:
Instructions
Create a user id (for example: automation2) that is only to be used for changes that do not cause notifications
Unzip custom-mail-listener.zip
Get the source for the MailListener.java code from the JIRA source code for your version of JIRA
Normally found in .../jira/src/java/com/atlassian/jira/event/listeners/mail
Add it to the source directory in the correct location (replacing the stub)
Modify it to be something like:
protected void sendNotification(IssueEvent event) { if (event.isSendMail()) { if (log.isDebugEnabled()) { log.debug("Event user: " + event.getRemoteUser().getName()); } if (!("automation2".equals(event.getRemoteUser().getName()))) { GenericValue projectGV = event.getIssue().getProject(); GenericValue notificationScheme = notificationSchemeManager.getNotificationSchemeForProject(projectGV); if (notificationScheme != null) { createMailItems(notificationScheme, event); } } else if (log.isDebugEnabled()) { log.debug("Ignore sending notification for event by user: " + event.getRemoteUser().getName()); } } }
From the directory you created with the unzip, run atlas-mvn compile
Copy the generated class file to your JIRA installation
Look in .../atlassian-jira/WEB-INF/classes/com/atlassian/jira/event/listeners/mail
Copy the shipped version somewhere for back
Replace with your compiled version
Restart JIRA
Use on your automation CLI command:
java -jar .../atlassian-cli/release/jira-cli-x.x.x.jar --user automation2 ...
Built Classes
Here are classes that have already been built using automation2 as the name for specific JIRA releases. You will need to rename the class to MailListener.class