I have a project where we manage release, now there are over 500 people using that project and sometimes people from the same team can raise issue with the same details.
I want to stop people from creating another issue which contains the same "Component" and "Region" only for a specific fix version. For every single component only 1 issue should be raised from a particular region I do not want two issues for a component with same region values.
Can I use the Create transition validator to restrict this and if yes then can someone please help me with the jql or groovy script.
Here is an example of running a JQL query within a Groovy script, so perhaps you can leverage this in a validator.
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
String jqlSearch = "project = jadmin" //modify this to check for a component and region for a specific fix version
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
UserUtil userUtil = ComponentAccessor.getUserUtil()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()
List<MutableIssue> issues = null
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
SearchResults searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.getResults().collect {issueManager.getIssueObject(it.id)}
//if issues count is > 0, then fail validation
} else {
log.error("Invalid JQL: " + jqlSearch);
}
Hi @Payne
So like there are more than 37 components and 4 regions, is there any way to write the code dynamically instead of mentioning all the components for all regions that too for a specific fix version
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm thinking you can define the jqlSearch variable to be something like this:
jqlSearch = "component = " + issue.component + " and region = " + issue.region + " and fixVersion = " + issue.fixVersion;
If that returns 1 or more issues, then fail validation.
I don't know offhand if region is a system field or a custom field; if custom, you will need to get it differently than issue.region. You may also need to wrap the data elements in quotes to handle embedded spaces, e.g. "component = " + "\"" + issue.component + "\""
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.