This issue has been created
There are 2 updates.
 
 
JIRA Components / cid:jira-generated-image-avatar-d7198960-e98c-4d7a-ba89-c17fb997b88d JIRA-120 Open

The JIRA Scripting API cannot be used from Velocity

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-9edde701-f16c-40f5-a9d4-7d92c1127aba Vincent Massol created this issue on 27/Jul/26 22:26
 
Summary: The JIRA Scripting API cannot be used from Velocity
Issue Type: cid:jira-generated-image-avatar-d7198960-e98c-4d7a-ba89-c17fb997b88d Improvement
Affects Versions: 8.2
Assignee: Unassigned
Components: API
Created: 27/Jul/26 22:26
Priority: cid:jira-generated-image-static-major-d6dbcbf4-39a3-49f5-a179-ef2a845b5253 Major
Reporter: Vincent Massol
Description:

Problem

$services.jira (JiraScriptService in jira-api) exposes exactly one public method:

public JiraRestClient getJiraRestClient(JIRAServer jiraServer)

A Velocity script has no way to obtain a JIRAServer instance:

  • Velocity cannot instantiate objects, so new JIRAServer(...) is not an option.
  • $services.component.getInstance() takes a java.lang.reflect.Type, which Velocity cannot produce, since getClass() and Class.forName are blocked by SecureUberspector.

The getJiraRestClient(String jiraURL, AuthenticationHandler) overload is private, and there is no getJiraRestClient(String serverId) method. The scripting API is therefore usable from Groovy only.

This looks like a lost capability rather than a deliberate choice: the commit that introduced the module (XWIKI-6879, 2011) says "Make it possible to use it from Velocity", and the documentation on extensions.xwiki.org carried Velocity examples calling $services.jira.getJiraRestClient($serverId) - a method that has never existed in this repository. Those examples were dropped when the documentation was migrated to xwiki.org, and the new page documents Groovy only, with the gap stated in its FAQ.

Suggested fix

Add a public getJiraRestClient(String serverId) that resolves the id against JIRAConfiguration.getJIRAServers(), so a Velocity script can use an instance declared in the JIRA administration section.

 
 

2 updates

 
cid:jira-generated-image-avatar-9edde701-f16c-40f5-a9d4-7d92c1127aba Changes by Vincent Massol on 27/Jul/26 22:28
 
Description: h2. Problem
{{$services.jira}} \({{JiraScriptService}} in {{jira\-api}}\) exposes exactly one public method:

{code:language=java}
public JiraRestClient getJiraRestClient(JIRAServer jiraServer)
{code}

A Velocity script has no way to obtain a {{JIRAServer}} instance:

* Velocity cannot instantiate objects, so {{new JIRAServer\(...\)}} is not an option.
* {{$services.component.getInstance\(\)}} takes a {{java.lang.reflect.Type}}, which Velocity cannot produce, since {{getClass\(\)}} and {{Class.forName}} are blocked by {{SecureUberspector}}.

The {{getJiraRestClient\(String jiraURL, AuthenticationHandler\)}} overload is {{private}}, and there is no {{getJiraRestClient\(String serverId\)}} method. The scripting API is therefore usable from Groovy only.

This looks like a lost capability rather than a deliberate choice: the commit that introduced the module \(XWIKI
\ -6879, 2011\) says "Make it possible to use it from Velocity", and the documentation on extensions.xwiki.org carried Velocity examples calling {{$services.jira.getJiraRestClient\($serverId\)}} \- a method that has never existed in this repository. Those examples were dropped when the documentation was migrated to xwiki.org, and the new page documents Groovy only, with the gap stated in its FAQ.

h2. Suggested fix
Add a public {{getJiraRestClient\(String serverId\)}} that resolves the id against {{JIRAConfiguration.getJIRAServers\(\)}}, so a Velocity script can use an instance declared in the JIRA administration section.

Labels: regression