Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adjust issue rank by groovy script

Deleted user July 27, 2016

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";
else
   println "Error: " + outcome.getErrorCollection().getErrorMessages();


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

 

Hopefully someone can help me.

 

Best regards

Benjamin

 

2 answers

0 votes
Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2016

Hi Benjamin,

You need something like

//your imports
@WithPlugin("com.pyxis.greenhopper.jira")
def rankService = PluginModuleCompilationCustomiser.getGreenHopperBean(RankService)
//your code....

please let me know if you need further assistance

regards

Thanos

Yagnesh Bhat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 14, 2019 edited

@Thanos Batagiannis [Adaptavist], what is the fully qualified classname of this class : 

 PluginModuleCompilationCustomiser

that I need to import? 

0 votes
Deleted user July 28, 2016

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

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events