Script Runner validation of (JQL > Script)

Gonchik Tsymzhitov Community Champion Oct 24, 2016

Hi guys, 

 

I want create a simple validator via groovy where goal is anyone can not resolve issue with resolution fixed without relations any commits with itself. 

For check, I use jql expression 

 

issue.property[development].commits > 0

But I don't know how convert to validator. 

 

Thank you.

 

 

1 answer

This widget could not be displayed.
Vasiliy Zverev Community Champion Oct 31, 2016

Here is code for simple script validator which makes a loop for all issue commets. Note, that a comment should be inserted before transition.

More one solution - you can make field "Comment" to be filled on transition screen with validator "fields requared" provided by JSU plugin.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.user.ApplicationUser

ApplicationUser curUser = ComponentAccessor.getJiraAuthenticationContext().getUser(); 

for(Comment comment: ComponentAccessor.getCommentManager().getComments(issue)){
  if(comment.getAuthorApplicationUser().equals(curUser))
   return true;
}
return false
Gonchik Tsymzhitov Community Champion Oct 31, 2016

Many thanks, Vasiliy. 

But I mean about commit from development tab. 

https://answers.atlassian.com/questions/32535478

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.plugin.devstatus.api.DevStatusSummaryService
import com.atlassian.jira.plugin.devstatus.rest.DetailBean
import com.atlassian.jira.user.ApplicationUser
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
 
@WithPlugin("com.atlassian.jira.plugins.jira-development-integration-plugin")
DevStatusSummaryService devStatusSummaryService = ComponentAccessor.getOSGiComponentInstanceOfType(DevStatusSummaryService.class)
 
ApplicationUser currentUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
 
DetailBean commitData = devStatusSummaryService.getDetailData(issue.id, "stash", "commit", currentUser).get()

 

But it's very I think to resolve via jql exression.

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

225 views 1 3
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you