JEMH Installation for Jira 3.9.2 - Jira 3.13.x
JEMH Installation
- Add the JEMH JAR
Get the JAR specific for your version of Jira from the top of the page and copy to the Jira WEB-INF/lib folder - Add the ldaputils jar (if you use ldap)
Get the latest ldaputils jar (currently 1.0.13) from the LDAP Util library page, take the example-ldaputil.properties file from the JAR and rename it ldaputil.properties, editing it as appropriate - Setup Logging (optional)
Modify / copy-and-modify the WEB-INF/classes/log4j.properties , this will enable logging of all EMH messages to a separate file. Default is DEBUG, other values are 'INFO', 'WARN' and 'ERROR'.# # Create a separate appender # log4j.appender.EMHFileLog=org.apache.log4j.RollingFileAppender log4j.appender.EMHFileLog.File=atlassian-jira-emh.log log4j.appender.EMHFileLog.MaxFileSize=20480KB log4j.appender.EMHFileLog.MaxBackupIndex=5 log4j.appender.EMHFileLog.layout=org.apache.log4j.PatternLayout log4j.appender.EMHFileLog.layout.ConversionPattern=%d %t %p [%c{4}] %m%n log4j.appender.EMHFileLog.Threshold=DEBUG # # add entries for the three EMH packages # log4j.logger.com.dolby.atlassian.jira.service.util.handler=DEBUG, EMHFileLog log4j.additivity.com.dolby.atlassian.jira.service.util.handler=false log4j.logger.com.dolby.atlassian.jira.service.util.handler.emh=DEBUG, EMHFileLog log4j.additivity.com.dolby.atlassian.jira.service.util.handler.emh=false log4j.logger.com.dolby.atlassian.jira.service.util.handler.emh.processor=DEBUG, EMHFileLog log4j.additivity.com.dolby.atlassian.jira.service.util.handler.emh.processor=false log4j.logger.com.dolby.atlassian.jira.service.util.handler.emh.service=DEBUG, EMHFileLog log4j.additivity.com.dolby.atlassian.jira.service.util.handler.emh.service=false
Enabling detailed logging of lower level mail operations in Jira is covered in Logging email protocol details.
What no log file?
Whether working on Windows or Linux, a lack of recently updated atlassian-jira.log and atlassian-jira-emh.log usually means file permissions are at fault....
- Make Jira aware of the new handler
Update WEB-INF/classes/services/com/atlassian/jira/service/services/pop/popservice.xml to include:
POP / Imap?
This example shows how to setup with POP, Imap is equally possible, just not documented, to use Imap, reconfigure Dovecot, and instead of modifying .../pop/popservice.xml modify .../imap/imapservice.xml.
<value> <key>com.dolby.atlassian.jira.service.util.handler.CreateOrCommentHandler</key> <value>Extendable Mail Handler - CreateOrComment</value> </value>
- Ensure a valid POP Sever is configured
This is under Global Settings/Mail Servers. If the virtual mailbox approach is used, only one mailbox needs to be setup, in the example shared@jira.myco.net:
- Configure the handler
Modifiy the two properties files. when done, they should be copied to WEB-INF/classes:
If you use ldap, the minimum config required is to identify a valid user which is used to validate ldap connections. If not, you don't need this file.
The EMH config file is just an extension of the properties that a mail handler is given, anything you could put in the Jira UI, you can equally add here. Look at the settings, understand what they do, make changes as appropriate for your needs.
The contents of the configuration file changes as new features are added and refinements are made, check the 'example-emh.properties' available inside every JAR.
Some example properties are:
projectAutoAssign=true, issuetype=3, configFile=emh.properties
Service Properties:
Service listing after save:
- Restart Jira
JEMH Handler Configuration File
The following sections describe the fields that can be used to configure JEMH. Organised by where they are used, in future I will try to expand on the documentation and provide more detailed examples.
as of 0.7, all 'default' fields are prefixed with default, eg defaultPriority etc. for clarity.
An example configuration file is packaged in every JAR, called 'example-emh.properties', contrast this file to your local file for changes.
Option |
Example value |
Description |
---|---|---|
notifyUsers |
true |
Notifies users if their accounts are created, also used to notify users on issue creation, necessary when users are anonymous and would like notification of issue details. |
notifyUsersOnIssueCreation |
none|nonjira|jira|all |
This provides a way for users to be notified of email driven issue creation irrespective of any other system or user configuration options |
assignNonJiraUsersOriginalEmailAddressToCustomField |
afieldname |
As the excessively descriptive field describes, will populate the given custom field with String value of the email address in CSV fashion. This value can also be populated as a directive... This is a security risk, just knowing the issue key (guessing even) would enable anyone with email access to add themselves into the issue. Default is disabled. To Fix (JEMH-51) |
defaultReportUsername |
abod |
identifies a 'default' user for anonymous email submission |
defaultIssueType |
3 or bug |
default issue type for created issues |
defaultPriority |
3 or critical |
default priority for created issues |
defaultIssueLinkType |
relates |
default link type for linked issues |
defaultProject |
APROJ|Magic Project|10002 |
an identifier for a project |
defaultComponent |
Some Component|10012 |
an identifier for a component in the given project |
whitelistSenders |
(.*)@(.*)yourco.net |
A regexp CSV list. If set, no other domains/accounts will succeed (implying blacklist of other domains), the blacklist can be used to further restrict within the whitelisted domains. If not set, all address will pass. Supports java5 regular expressions |
blacklistSenders |
postmaster@xyz.com,(.*)@(.*)otherco.net |
A regexp CSV list of addresses that will not be processed by Jira, and will be automatically forwarded (if silently drop not set) to the configured 'forwarder' of the related Mail Service, java5 regexp supported |
blacklistRecipients |
jira-noreply@yourco.net,noemailprojectkey@yourco.net |
as above |
silentlyDropBlacklistMatches |
true |
If set to false, causes blacklisted mails to not be forwarded, dropping all of them. Possibly useful for high volume environments, blacklisted mails will always be deleted |
greylistSenders |
postmaster@yourco.net,.*@yourco.com |
CSV regexp list of address that might get blocked depending on subject |
greylistSendersSubjectRegexps |
Delivery to the following recipients failed,.*Delivery Status Notification.*Failure.* |
CSV regexp list, for greylist subject matches |
greylistRelatedUserBodyRegexp |
[ ]*to:[ ]((.*)@(.*))$ |
Enables to: addresses on system generated emails to be extracted, and related users tested for being active, inactive users make the related mail a match |
silentlyDropGreylistSubjectMatches |
true |
If set to false, causes blacklisted mails to not be forwarded, dropping all of them, if true. |
emailFieldProcessorPriorityLowerLimit |
0 |
If set will set the lower priority limit that processors are enabled, allowing users to configure just a subset of available field processors to be executed in priority order (procPri>=lowerLimit and procPri<=upperLimit). Eg, MailFormNgProcessor=1000, CSVProcessor=10000, 'default' Atlassian Processor=2147483647 |
emailFieldProcessorPriorityUpperLimit |
2147483647 |
As above, but the upper limit |
CommentHandler
Option |
Example value |
Description |
---|---|---|
stripQuotes |
false |
strips > comment lines from included emails when Jira emails are replied to. Overrides system default settings to forward an entire email (from outside Jira) including comments, into a Jira ticket. |
AbstractFieldProcessor
Option |
Example value |
Description |
---|---|---|
debugPrintEmail |
true |
will print out emails as they are received for debugging |
alternateIDLookupClassList |
x.y.AClass,p.q.BClass |
List of classes used to do email -> ID lookups |
domainEquivalency |
my.co.uk:my.com |
related to LDAP provider, indicates given domains 'are the same'. _You will need to set this to your domains 'aliases' for ldap alternate lookup to work |
emailFieldProcessorClassList |
x.y.AClass,p.q.BClass |
List of classes used to process emails |
projectAutoAssign |
true |
attempt to get the project Key from the to: address (useful if you have a combined destination mailbox) |
forceUserIdCase |
true |
will force the case of userids for lookups, required for case sensitive DB's |
lowercaseUserids |
true |
if true will force lowercase, false or missing indicates upper case |
catchEmail |
xyz@jira.myco.net |
for use with the Basic field processor, enables a common email account to only have email retrieved for the given 'catch' addressee |
createUsers |
true |
enables on the fly creation of users, whether being the 'sender' or a 'watcher', however so determined. |
createUsersIDFrom |
name/email/alternate |
enables the selection of userid to be derived from the name part of the email, the full email, or via the alternate ID provider framework (there is an AD LDAP provider included in the project |
createUsersIDFromEmailDomainWhitelist |
.*@myco.net,.*@,myco.com |
Enables user creation to be be restricted to given domains |
createUsersIDFromEmailBlacklist |
sales@atlassian.com |
Stops emails from sales@atlassian.com (or any other regexp), from being used as a valid userID |
notifyUsers |
true |
notify users of issue creation |
deleteEmail |
true |
if set to false, will prevent Jira from deleting mails from the mailbox after processing |
autoFlushMailQueue |
true |
will cause the Mail Queue to be flushed whenever the EMH handler is run (which only occurs when there is mail to process) |
addWatchersFromCC |
true |
will make all valid users watchers of the created issue, in addition to anything that may be set as directive |
createUsersIDFrom |
email|name|alternate |
select mechanism for determining the userID, email is user@someplace.com, name is user@somplace.com, alternate means use the alternateID provider classes |
autoJoinGroup |
email-users |
enables auto-created users to be automatically joined to a given group |
indicateWhichProcessorProcessedMail |
true/false |
causes a one liner to be inserted at the top of the jira issue, to assist in debugging, or as an indicator for where the issue came from |
ccHandling |
toWatcher|toCustomField |
will cause users to be derived from email cc: entries as well as from the directive ccusers, to be added as watchers to the issue or to be merged into a given custom field (must be capable of accepting user type, eg MultiUserCF type |
ccHandlingTargetCustomFieldName |
Some CF Name |
If the ccHandling field indicates a custom field should be used, this field idetifies that field by name, whitespace allowed |
JEMH Poker Installation
This JEMH Poker is a simple javaapplication that triggers the JEMH to do an immediate mail retrieval. The current 1.0 release of the JEMH Poker contains a simple file monitor, suitable for most Unix or Linux platforms and associated file-based mail systems. Exchange is an unknown quantity, as Microsoft products are not known for their openness - the approach I took in my organization was to use Exchange purely as a vehicle to get mail to where I could do something useful with it (see setting up Postfix smtp server and Dovecot POP server pages here).
Installation of the remote agent
- Extract the tgz in /usr/local
cd /usr/local tar xzf filename.tgz
- Make the launch shell script executable
cd jemh-mail-notifier-...... chmod +x *.sh
- Link a common name to the current version
ln -s jemh-mail-notifier-...... jemh-mail-notifier
- Ensure you have Java in your path, the following should give some version information. If not, install Java 1.5+ or modify the script (you should know what to do)
java -version
- Edit the configuration file emh-poker.properties, set the server (IP address or DNS name) and the port (default is 7777).
- Run the script as the appropriate user for your environemnt. With Postfix, you may need to be running as Postfix. Running as root is to be avoided, create a service user as follows:
root@server:/usr/local/jemh-mail-notifier-1.1-SNAPSHOT# adduser --disabled-login --no-create-home -ingroup postfix jirapoker Adding user `jirapoker' ... Adding new user `jirapoker' (1009) with group `postfix' ... Not creating home directory `/home/jirapoker'. Changing the user information for jirapoker Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y
Create a SysV startup script in /etc/init.d
Create it as 'jemh-mail-notifier'
#! /bin/sh ### BEGIN INIT INFO # Provides: jemh-mail-notifier # Required-Start: # Required-Stop: # Default-Start: 2 # Default-Stop: # Short-Description: Monitors a mailbox and poke jira when mail arrives ### END INIT INFO PATH=/sbin:/bin . /lib/lsb/init-functions case "$1" in start) cd /usr/local/jemh-mail-notifier ./run.sh & ;; stop) # No-op echo Cant stop it from here, use 'ps -ef | grep java' at the prompt ;; *) echo "Usage: $0 start" >&2 exit 3 ;; esac
To make the service start at bootup:
sudo apt-get install sysvconfig sysvconfig
Now find the jemh-mail-notifer and enable for startup, click finish to save.
Installing the Jira JEMH Poker Service
The main JEMH includes everything necessary, the only thing that's required is a bit of configuration:
- Login to Jira as admin
- Go to the Services screen
- Add a service:
Name
JEMH Poker Service
Class
com.dolby.atlassian.jira.service.util.handler.emh.service.EMHPokerService
Delay
1 note: this is essentially the delay in initial startup as Jira starts
- Select the default port options or change as you see fit (must fix Poker configuration, above)
After configuring you should see something like:
Poker Sequence Diagram
Space Map
Table of Contents