You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi there
We have upgraded our Jira Development System from Jira 7.x to the Enterprise Release Jira 8.5.
I had noticed that the Jira API has breaking changes in the Class com.atlassian.jira.issue.search.SearchProvider, which results in several of my Scriptrunner Scripts being broken.
As we have an important Plugin that is not yet compatible with Jira 8.5, I am stuck with Jira 7 in Production and Jira 8 in our Development environment.
I have tweaked my systems, so that both Jira Versions 7 and 8 can run the same Scriptrunner Code.
I would like to share this with you here.
/*
BisonHelper for Jira 7
*/
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
public class BisonHelper {
public static com.atlassian.jira.issue.Issue[] getIssuesByJQL(String jqlQuery) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser);
def searchProvider = ComponentAccessor.getComponent(SearchProvider);
def query = jqlQueryParser.parseQuery(jqlQuery);
def results = searchProvider.searchOverrideSecurity(query, user, PagerFilter.getUnlimitedFilter(),null)
com.atlassian.jira.issue.Issue[] returnVal = []
return returnVal = results.getIssues()
}
}
/*
BisonHelper for Jira 8
*/
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.issue.search.SearchQuery
public class BisonHelper {
public static com.atlassian.jira.issue.Issue[] getIssuesByJQL(String jqlQuery) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser);
def searchProvider = ComponentAccessor.getComponent(SearchProvider);
def query = jqlQueryParser.parseQuery(jqlQuery);
def searchQuery = SearchQuery.create(query, user).overrideSecurity(true);
def results = searchProvider.search(searchQuery, PagerFilter.getUnlimitedFilter())
com.atlassian.jira.issue.Issue[] returnVal = []
return returnVal = results.getResults()*.document.collect{ComponentAccessor.issueManager.getIssueObject(it.getField('key').stringValue())}
}
}
Now you can rewrite your code using the BisonHelper Class so that it is compatible with both systems.
def issues = BisonHelper.getIssuesByJQL('project=TEC')
for (it in issues) {
log.warn('found issue: ' + it.key)
}
After the productive upgrade, all you need to do is re-link your BisonHelper.groovy link to the BisonHelper_V8.groovy file and all will work.
A very beneficial side-efect:
The wrapper is much easier to use than building the native code.
To get issues in a script you dont need to figure out how to build the query result anymore and there is no need bothering which classes you need to import!