An email preprocessor for use with Jira's email handler, adding a wiki-formatted block of headers to the top of the email body
Don't hardcode specific versions of bundler and rake. Newest releases are very likely to work

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~redradishtech/jira_email_preprocessor
read/write
ssh://hg@hg.sr.ht/~redradishtech/jira_email_preprocessor

#Jira_email_preprocessor

A utility for use with Jira's email handler, adding a wiki-formatted block of headers to the top of the email body, e.g.:

{noformat}
From: jeff@random.com
To: jira@example.com
Subject: [ac-680] Hello world
Date: Mon, 28 Jan 2019 13:08:38 +1100
{noformat}

#Installation

For a self-contained binary, I would do it this way:

  1. Install Ruby and bundler. My go-to guide is https://frontendgods.com/getting-started-with-ruby-for/

  2. Clone this repo, e.g:

    hg clone ssh://hg@hg.sr.ht/~redradishtech/jira_email_preprocessor
    

    I personally keep the repo in /opt/atlassian/jira/current/emailprocessing/, version-controlled with other Jira config items.

  3. Build using bundler

    bundle install

    Thanks to a built-in .bundle/config file, the dependencies will be self-contained to the directory in vendor/

  4. Generate binary stubs

    bundle binstub ${PWD##*/}

You should now have a bin/jira_email_preprocessor that can be invoked from anywhere.

#Testing

Create a test email:

cat <<EOF > /tmp/testemail
From: joerandom@localhost
To: ac-680@example.com
Subject: Testing to jira

Testing comments from Jira.

EOF

Pipe our test email through the script, as the user that will eventually run the script (here, jira). If successful, the body will contain a new {noformat} block:

# cat /tmp/testemail | sudo -u jira /opt/atlassian/jira/current/emailprocessing/jira_email_preprocessor/bin/jira_email_preprocessor
From
Date: Mon, 28 Jan 2019 22:25:12 +1100
From: joerandom@localhost
To: ac-680@example.com
Message-ID: <5c4ee698a0e87_2ab62abd8d7390cc2658a@coastserver.mail>
Subject: Testing to jira
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

{noformat}
From: joerandom@localhost
To: ac-680@example.com
Subject: Testing to jira
{noformat}
Testing comments from Jira.

#Usage

Typically jira_email_preprocessor will be invoked from procmail with:

# Since JIRA will be CC'ed on email correspondence, we want to include a few important email headers in the comment. 
:0wfhb
| path/to/jira_email_preprocessor/bin/jira_email_preprocessor

#License

The gem is available as open source under the terms of the MIT License.