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

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Fadoua M. Boualem
Published yesterday in Trello

Using Trello to manage events

As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...

451 views 6 7
Read article

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