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

Your Points Tracker
  • 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
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?
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

Groovy script Regex Matcher issue

We are tying to create a listener on VersionCreate. The listener will check if the version matches a particular pattern and execute some steps.  here is the code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.project.VersionCreateEvent
import java.text.SimpleDateFormat
import com.atlassian.jira.project.version.VersionManager
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import java.util.regex.*

customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueService = ComponentAccessor.issueService
def projectManager = ComponentAccessor.projectManager
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def project = projectManager.getProjectObjByKey("TESTS")
def newIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(project).find { == "Test Plan" }
def event = event as VersionCreateEvent

// Construct The Pattern to Match on SP
Pattern patternSP = Pattern.compile('SP')
log.warn("Pattern : ${patternSP}")
log.warn("Version Name : ${}")
Matcher matcherSP = patternSP.matcher(
log.warn("Matcher : ${matcherSP}")
log.warn("Matching Results : ${matcherSP.find()}")

// Construct The Pattern to Match on HF
Pattern patternHF = Pattern.compile('HF')
log.warn("Pattern : ${patternHF}")
log.warn("Version Name : ${}")

Matcher matcherHF = patternHF.matcher(
log.warn("Matcher : ${matcherHF}")
log.warn("Matching Results : ${matcherHF.find()}")

if(matcherSP.find() && !matcherHF.find())
.warn("SP Release")
else if (!matcherSP.find() && !matcherHF.find())
log.warn("Major Release")
else { "HF will not have any test plans"}

But this always should the message "Major Release" for any value that is entered for the version. Here is what should be displayed:

2019.10 : "Major Release"

2019.10-SP1 : "Service Pack"

2019.10-SP1HF : "HF will not have any test plans"

Is this implementation is correct? Is there an alternate way to implement this logic?

1 answer

hi Krishna, I am also looking for same kind of fix. I need to update the trigger for release version using Regex, for example, Release version = 2020.01.0.1

Suggest an answer

Log in or Sign up to answer
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...

75 views 0 4
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