Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

button-

...

handy

...

blanktrue
color

...

#0052CC
nameSend Feedback
linkhttps://

...

docs.

...

google.

...

com/forms/

...

d/

...

e/

...

1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=Replicate+the+native+Jira+email+handler+-+15482067
widthauto

This script is run by the SIL email handler to process an incoming email in the same manner as JIRA's default Create issue or add comment email handling option.

To use this script, you will have to modify the destination projectKey and issueType for your purposes.

Code Block
IncomingEmail mail = getIncomingEmail();

string issueKey = matchText(mail.subject, "[A-Z][A-Z]+-[0-9]+"); // find an issue key in the subject
if(isNull(issueKey)) {
    // if no issue key found, create a new issue
    string [] fields = {};
    fields += {"reporter", getUserByEmail(mail.from[0]).key};
    fields += {"assignee", getUserByEmail(mail.to[0]).key};

    string newIssue = createIssue(
      "PROJ", //projectKey
      "", //parentIssueKey
      "Task", //issueType
      mail.subject, //summary
      "Medium", //priority
      mail.body, //description
      {}, //components
      "", //dueDate
      "", //estimate
      "", //security_level
      fields //custom_fields_mappings
    );
    attachAllFilesFromEmail(newIssue);
    %newIssue%.watchers = getUserKeysFromEmails(mail.cc);
} else {
    // if issue key found in subject, add a comment
    addComment(issueKey, currentUserKey(), mail.body);
}