Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

IssueLinking in Jira 4.2 using Jelly Script

Anandhi A July 23, 2012

We are able to perform IssueLinking in Jira 4.2 using JellyRunner manually using the following command.

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

<jira:LinkIssue key="OKDAC-5640" linkKey="OKDAC-5641" linkDesc="is a duplicate of"/>

</JiraJelly>

Please can you tell me how to execute this script from Java code...I dont want to do this manually.I want to write a Java code to perform IssueLinking if i pass the Issue Keys. Please tell me how to do this. Thanks in advance.

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Renjith Pillai
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 28, 2012

If you are okay with dealing with HTTP requests you can do a simle POST command to the URL with the content data as below (of course with os_username and os_password parameters). I quicky saw this being POSTed by JIRA. You need to also figure out which are the form parameters which JIRA identifies to get the source issue key.

http://<<yourjira>>/secure/LinkExistingIssue.jspa

POST: linkDesc=relates+to&linkKey=<<issueIdToLink>>&comment=

Anandhi A July 29, 2012

Thanks Renjith..

This works fine...But its requires an atlassian token to perform this operation.Is there any way to get the token generated??

Anandhi A July 29, 2012

Thank You Renjith and Jobin...:)

0 votes
Jobin Kuruvilla [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 25, 2012

If you want to run the Jelly scripts automatically, you should use the Jelly runner services. You can add it under Services and point to your script.

If you want to run it from a Java program, why do you need a Jelly script? Use JIRA JAVA APIs.

Jobin Kuruvilla [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 25, 2012

Wait, jelly code cannot be executed remotely. It is not a substitute for SOAP/REST APIs. Whatever you do with Jelly, you can do with a plugin.

And if you need to execute the already written code using Java, that must be a task or a service. As I said, you already have a Jelly service that can do this.

Anandhi A July 25, 2012

Oops...I found this code in some website and tried executing it.

I have created a custom service in Jira 4.2 with this jelly script.

Is it possible to execute this from command prompt?? I saw somewhere that

org.apache.commons.jelly.Jelly executes the script that we create. But i dont know how to do it. Can you help me with this.

Thanks in advance.

Anandhi A July 25, 2012

Jobin,

I use this script to link 2 existing issues in Jira 4.2. I was not able to link issues using SOAP API or REST. I already posted a thread and concluded based on the replies that its not possible to link remote issues in JIRA 4.2 through APIs. So went for Jelly Script.

But i need some java code in front to execute the script.

Anandhi A July 26, 2012

is it possible to use a jelly:soap tag to login to jira using soap wsdl url and execute this script from the above java code???

I am actually suppose to do Remote IssueLinking from java. But i learnt that its not possible in JIRA 4.2 and SOAP API. Is there any way to do this from java??

I tried to creaet a Service in JIRA 4.2 with the Jelly Script as the input and xml output. I filled the script into the text file from java code and made that service execute the script and generate output. But output is generated only after 2 minutes when the Service delay time is 1 minute. This doesnt work out.

I tried to do it via Http POST rquest from URL. I can fill the script in the Text Area specified in Jelly Runner. But cannot execute.

Please can you tell me what am i to do with this Issue Linking...

Thanks in advance.

Anandhi A July 26, 2012

Jobin, Since we are not able to do issue linking in JIRA 4.2 using SOAP API and REST API we are using jelly scripts to solve the problem as a work around.

Please let me know how we can execute a jelly script using HTTP POST method from java code. We had tried to use the JellyRunner.jspa URL to post the jelly script but not able to do it. Please help.

zaccraven January 16, 2015

I also wish to know how to execute a jelly script using HTTP POST.

zaccraven January 16, 2015

or better, HTTP GET

0 votes
Anandhi A July 25, 2012

Is there any way to execute this Jelly Script from command line or through Http post requests using Java Code...?

0 votes
Anandhi A July 24, 2012

We have written the following Java code to execute a Jelly Script.

File file = new File("IssueLinking-Jelly.jelly");	
Writer someWriter = new FileWriter( "output.xml");
XMLOutput output = XMLOutput.createXMLOutput( someWriter );
JellyContext context = new JellyContext();
context.runScript(s, output );
System.out.println(output.toString());

And also modified the Jelly Script as

&lt;JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib"&gt;
&lt;jira:Login username="loginname" password="loginpwd"&gt;
&lt;jira:LinkIssue key="issuekey1" linkKey="issuekey2" linkDesc="duplicates"/&gt;
&lt;/jira:Login&gt;
&lt;/JiraJelly&gt;

But it throws the following exception.

org.apache.commons.jelly.JellyTagException: Sync1/IssueLinking-Jelly.jelly:2:53:
&lt;jira:Login&gt; com.atlassian.jira.jelly.tag.login.Login
doesn't have any satisfiable constructors.
Unsatisfiable dependencies:
[[interface com.atlassian.jira.security.JiraAuthenticationContext]] at
org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:671)
at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:259)
at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
at org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:102)
at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:704)
at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
at org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:621)
at com.mmi.firebirdodartsync.IssueDuplication.main(IssueDuplication.java:85)
Caused by: org.picocontainer.defaults.UnsatisfiableDependenciesException:
com.atlassian.jira.jelly.tag.login.Login doesn't have any satisfiable constructors.
Unsatisfiable dependencies:
[[interface com.atlassian.jira.security.JiraAuthenticationContext]]

Please tell us how can this be solved.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events