Is it possible to execute JQL directly from a Jelly Script?

John Ryan August 24, 2011

I am trying to write a jelly script. The script needs to execute a filter to retrieve a list of issues (no problem). I then need to iterate through those returned issues (again no problem) and look at the linked issues that are associated with each issue. Jelly doesn't have a tag to get the list of linked issues so i was wondering if there was a way that I could execute a JQL query that called the JQL Tricks plugin that returns a list of linked issues. Alternatively if it was possible you could call a filter (that called the JQL Tricks plugin) and pass in the key of the issue but as far as I can see this is not possible.

1 answer

1 accepted

1 vote
Answer accepted
Matt Bates August 29, 2011

Yup but its very longwinded:

<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>

<core:invokeStatic className="java.lang.Class" method="forName" var="searchProviderClass">
<core:arg value="com.atlassian.jira.issue.search.SearchProvider"/>
</core:invokeStatic>
<core:invoke on="${componentManager}" method="getComponentInstanceOfType" var="searchProvider">
<core:arg value="${searchProviderClass}"/>
</core:invoke>
<core:new className="com.atlassian.jira.jql.parser.DefaultJqlQueryParser" var="queryParser"/>

<core:invokeStatic className="com.atlassian.jira.web.bean.PagerFilter" method="getUnlimitedFilter" var="UNLIMITED_FILTER"/>

<core:set value="status = Open" var="query"/>
<core:invoke on="${searchProvider}" method="search" var="queryResults">
<core:arg value="${queryParser.parseQuery(query)}"/>
<core:arg value="${jelly.user}"/>
<core:arg value="${UNLIMITED_FILTER}"/>
</core:invoke>

Pramod Kutty February 2, 2014

I tried the above script and am getting error

Error: <JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log">
Exception: org.apache.commons.jelly.JellyTagException: null:22:0: No such accessible method: search() on object: com.atlassian.jira.issue.search.providers.LuceneSearchProvider
java.io.PrintWriter@e5aa54

Jelly script is

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >

<jira:Login username="usr1" password="abc123">

<log:warn>Running Inactivate issues service</log:warn>

<core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>

<core:invokeStatic className="java.lang.Class" method="forName" var="searchProviderClass">

<core:arg value="com.atlassian.jira.issue.search.SearchProvider"/>

</core:invokeStatic>

<core:invoke on="${componentManager}" method="getComponentInstanceOfType" var="searchProvider">

<core:arg value="${searchProviderClass}"/>

</core:invoke>

<core:new className="com.atlassian.jira.jql.parser.DefaultJqlQueryParser" var="queryParser"/>

<core:invokeStatic className="com.atlassian.jira.web.bean.PagerFilter" method="getUnlimitedFilter" var="UNLIMITED_FILTER"/>

<core:set value="project = TRM and status = On hold" var="query"/>

<core:invoke on="${searchProvider}" method="search" var="queryResults">

<core:arg value="${queryParser.parseQuery(query)}"/>

<core:arg value="${jelly.user}"/>

<core:arg value="${UNLIMITED_FILTER}"/>

</core:invoke>

<core:forEach var="issue" items="${issues}">

<log:warn>Inactivating issue ${issue.key}</log:warn>

</core:forEach>

</jira:Login>

</JiraJelly>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events