Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
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

How to validate issue transition by *unreleased* fixVersion via either Power Script or ScriptRunner

Hi! 

I wanted to do a workflow validation where if a ticket does not have the latest unreleased version on it.

I expected that this should be possible at least with PowerScripts or ScriptRunner if not native Jira.

I've had little success:

I tried this:

if(size(key in silJQLExpression('', 'issueKey = ' + key + ' AND fixVersion in unreleasedVersions() AND not fixVersions in releasedVersions()'))) == 0){

return false, "fixVersion", "Fix Versions blablalbla.";

}
return true;

but it always says there's some error without any further info. 

 

Any hints on how to proceed?

1 answer

1 accepted

1 vote
Answer accepted
Leo Community Leader Mar 03, 2021

Hi @Šimon Demočko 

Below snippet will help you to check whether ticket is associated with released version or unreleased one

you can place this in validator or condition(scriptrunner functions)

def versions = issue.getFixVersions()
for (v in versions){
if(!v.isReleased()){
return true // there is at least one unreleased version hence returning true
}
}
return false

 

Hope this helps

 

BR,

Leo 

Thanks, looks great, I modified it a bit further into something like this: 


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.bc.issue.search.SearchService

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService.class)

def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def query = jqlQueryParser.parseQuery("issuekey = " + issue.key + " AND development[pullrequests].merged > 0")
def results = searchService.search(user, query, PagerFilter.getUnlimitedFilter())


if (results.total == 1 && issue.getResolution() in ["Fixed", "Done", "Resolved"]){
def versions = issue.getFixVersions()
if (versions.size() == 0) return false
for (v in versions){
if(!v.isReleased()){
return true
}
}
return false
}

Suggest an answer

Log in or Sign up to answer
TAGS

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