I am trying to build a query:
Fetch all the fix versions of a ticket, see if that fix version is assigned to any other tickets in the same project. Below script works fine for 6.X but it is throwing the below error in 7.X
Please help me to fix these errors.
Script69.groovy:61
[Static type checking] - Cannot find matching method com.atlassian.jira.ComponentManager#getSearchService(). Please check if the declared type is right and if the method exists.
@ line 61, column 47.
Script69.groovy:65
[Static type checking] - Cannot assign value of type com.atlassian.jira.user.ApplicationUser to variable of type com.atlassian.crowd.embedded.api.User
@ line 65, column 18.
Script69.groovy:66
[Static type checking] - Cannot find matching method com.atlassian.jira.bc.issue.search.SearchService#search(com.atlassian.crowd.embedded.api.User, com.atlassian.query.Query, com.atlassian.jira.web.bean.PagerFilter). Please check if the declared type is right and if the method exists.
Possible solutions: each(groovy.lang.Closure) @ line 66, column 16.
Issue curissue = issue curissuekey = curissue.getKey(); Collection<Version> fixVersionList = issue.getFixVersions(); if (fixVersionList.size() > 0) { for (Version v : fixVersionList) { fvname = v.getName(); JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder.where().project().eq("Project_name").and().fixVersion().in(""+fvname+""); Query query = builder.buildQuery(); SearchService searchService = ComponentManager.getInstance().getSearchService(); SearchResults results = null; try { User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); results = searchService.search(user, query, PagerFilter.getUnlimitedFilter()); } catch (Exception e){} nCount = results.getTotal(); } }
It seems that your issue is related of using the ComponentManager as your SearchService and that's deprecated in favor of the ComponentAccessor class.
The problem is here:
SearchService searchService = ComponentManager.getInstance().getSearchService();
Try changing it to this instead:
SearchService searchService = ComponentAccessor.getComponentOfType(SearchService.class);
Then there's another issue where you're trying to get the Current Logged in User and for that you'll need to import the ApplicationUser class as it changed as of Jira 7.x to use that instead of the atlassian.crowd class so simply add the following line on top of your code:
import com.atlassian.jira.user.ApplicationUser
Then change this code:
User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
To this one:
JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext() ApplicationUser user = authContext.getLoggedInUser()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.