Within Jira software projects you are able to set the visibility of each comment that is made. By default this is set to all users so that everyone is able to view the comments that have been made. This script will allow you to set the visibility of the comment based on certain conditions. The conditions are:

If all of these conditions are met then the Script will add “#viewable=Administrators” to the subject so that it can be matched by the Subject Field Processor which will set the visibility to Administrators. If any of these conditions are not met then the Script will not alter the email and as a result will not alter the comment visibility.

Note:

Example Script

var from = headerBeans.get('from').getOriginalVal();
var origSubject = headerBeans.get('subject').getOriginalVal();

if(origSubject.contains("[TEST-")) /*Project key to apply permission to */
{
    if(from !== null)
    {
        if(jemhUtils.getUserByEmail(from)) /*Checks if the sender is a Jira User*/
        {
            print(jemhUtils.getUserByEmail(from));
            
            if(ccAddresses == null && toAddresses.length == "1") /*Checks if the reply contains any extra Recipients*/
            {
                var newSubject = origSubject + " " + "#viewable=Administrators"; /*Adds a viewable condition to be captured by Subject Field processor*/
                headerBeans.get('subject').setUpdatedVal(newSubject);
                print(newSubject);
            }
        }
    }
}

Example Email

MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com>
Subject:  [TEST-40] This is an example issue
From: admin@localhost
To: mailbox@localhost
Content-Type: text/plain; charset=UTF-8


This is a comment

Report Output

Within the report it will show what the subject was changed to and that the Field Processor has matched on the added content.

Issue Page