Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Removing boilerplate from issue description and comments

We get a good amount of Jira tickets and replies from company e-mail accounts that include a large amount of set boilerplate legal language on the bottom of them. The e-mail parser we use (Enhanced Mail Handler) filters out the reply strings, but not the footer language.

Is it possible to remove a certain string (or one fitting a regular expression) whenever an issue description is created or when a comment is posted?

1 answer

Hello August.

Yes it is, however it would add quite a bit of load to your server if I am not mistaken. Basically you would set up a script listener that triggers on Issue Commented event and on IssueCreated event.

The listeners shuold parse the description in case of the IssueCreated event. And in case of the IssueCommented they would have to parse the commented text.

Do you need pointers as to how to do that or does this suffice?

Cheers

DYelamos

Hi Daniel,

  Thanks for your reply! I'm new to Groovy scripting, but I started with something like this:

import com.atlassian.jira.issue.Issue
def issue = event.issue as Issue
issue.description.replaceAll("This email was sent by a company .*", "")

My intention here was, on create or update, to remove all the text after the boilerplate language (hence the .*). But I don't think I'm using the Jira-relevant syntax just right here.

Hi August.

That doesn't have to do with JIRA. What you need to use there(first argument of the function "replaceAll") is a regular expression. I myself am not an expert, but I can recomend this article, that will teach you how to use that "...description.replaceAll(...)"

If you find anymore trouble, please do respond, and I'll spend some time crafting an example for you.

Cheers.

Dyelamos

Hi Daniel,

   I wasn't suggesting that this had to do with Jira per se, just that the syntax I was using the access the Jira issue might be incorrect. The first argument I supply above is actually a regular expression, taking the occurrence of zero more more chracters following that string and replacing it with the empty string. I'm just not versed in how I write the Jira issue with that, which seems not to be working. There seem to be a variety of ways to bring the issue in scope, but none of the syntax guides I've seen are clear on what will work in this case.

Ow okay. Now I get you.

First of all I don't think groovy regular expressions accept asterisk expansion, but if you say that works for you, I might be wrong.

If your code above does filter the right string, then:

You need to fetch the MutableIssue from that Issue.

That issue has a method called setDescription.

I believe this would work: 

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue

def issue = event.issue as mutableIssue
def newDesc = issue.description.replaceAll("This email was sent by a company .*", "")

issue.setDescription(newDesc)
issue.store()

Let me know if this works.

Cheers!

DYelamos

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

109 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you