Adjust issue rank by groovy script

Hi there


I want new tasks to be on the bottom of the backlog. Now I have the issue that in JIRA 7.1.6 the RankService does not seem to be available anymore and I can not find what is wrong.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.ComponentManager
import com.atlassian.plugin.PluginAccessor
import com.atlassian.jira.bc.project.ProjectService
import com.atlassian.greenhopper.service.rank.RankCustomFieldService
MutableIssue myIssue = (MutableIssue) event.issue;
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
Class rankServiceClass = pluginAccessor.getClassLoader().findClass("com.atlassian.greenhopper.service.rank.RankCustomFieldService");
def rankService = ComponentAccessor.getOSGiComponentInstanceOfType(rankServiceClass);
def rankField = rankService.getDefaultRankField();
def outcome = rankService.rankLast(user, rankField.getIdAsLong(), myIssue);
if (outcome.isValid())
   println "Re-ranked";
   println "Error: " + outcome.getErrorCollection().getErrorMessages();

import com.atlassian.greenhopper.service.rank.RankCustomFieldService can not be found


Hopefully someone can help me.


Best regards



2 answers

Anyone here? Maybe some help on a useful documentation so I might find it myself?

Hi Benjamin,

You need something like

//your imports
def rankService = PluginModuleCompilationCustomiser.getGreenHopperBean(RankService)
//your code....

please let me know if you need further assistance



Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,149 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot