We are in the process of implemention Jelly scripts as per Atlassian's Jelly Escalation examples. Whilst we can get them to work as-is, what we would like to do is include the issue reporter's name in the comment.
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"> <jira:Login username="****" password="********"> <log:info>Running close resolved issues service</log:info> <!-- Properties for the script --> <core:set var="comment">Hello XXXX, This issue has been in state 'Resolved' for one week and has now been closed. If this issue has not been completed or you are not satisfied with the resolution, please reopen the issue and we will respond as soon as possible. Thank you.</core:set> <core:set var="workflowStep" value="5"/> <core:set var="workflowUser" value="****"/> <core:set var="filterID" value="10501"/> <!-- Run the SearchRequestFilter --> <jira:RunSearchRequest filterid="${filterID}" var="issues"/> <!-- Iterate over the issues --> <core:forEach var="issue" items="${issues}"> <log:info>Closing resolved issue ${issue.key}</log:info> <jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" comment="${comment}"/> </core:forEach> </jira:Login> </JiraJelly>
I have tried various methods of obtaining the reporter's name, including those already asked on Atlassian Answers, but I am not able to get them to work on JIRA v5.1.7.
<core:invoke on="${issue}" method="getReporter" var="reporter"/>
Whilst the Jelly Runner accepts this, it doesn't seem to work. Therefore, please can you give us some guidance.
Thanks a lot!
Working solution as per Jobin's code suggestion:-
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"> <jira:Login username="****" password="********"> <log:info>Running close resolved issues service</log:info> <!-- Properties for the script --> <core:set var="workflowStep" value="5"/> <core:set var="workflowUser" value="****"/> <core:set var="filterID" value="10501"/> <!-- Run the SearchRequestFilter --> <jira:RunSearchRequest filterid="${filterID}" var="issues"/> <!-- Grab an instance of ComponentAccessor --> <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getIssueManager" var="issueManager"/> <!-- Iterate over the issues --> <core:forEach var="issue" items="${issues}"> <core:invoke on="${issueManager}" method="getIssueObject" var="issueObj"> <core:arg type="java.lang.String" value="${issue.key}"/> </core:invoke> <core:invoke on="${issueObj}" method="getReporter" var="reporter"/> <log:info>Closing resolved issue ${issue.key}</log:info> <jira:TransitionWorkflow key="${issue.key}" user="${workflowUser}" workflowAction="${workflowStep}" comment="Hello ${reporter.displayName}, This issue has been in state 'Resolved' for one week and has now been closed. If this issue has not been completed or you are not satisfied with the resolution, please reopen the issue and we will respond as soon as possible. Thank you."/> </core:forEach> </jira:Login> </JiraJelly>
Try this (note that upper case N):
${issue.reporter.displayName}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jobin,
Thank you for your help, but unfortunately it didn't appear to work.
Thanks though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how are you using it? what is the full code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jobin,
I originally tried the above code but with
${issue.reporter.displayName}
in place of XXXX, but realising that the comment variable had already been defined before the issue details were obtained and that it might not get refreshed, I then tried replacing the ${comment} placeholder with the comment string itself, but this didn't work either.
In order to see if the reporter name was being returned I replaced the forEach block with
<core:forEach var="issue" items="${issues}"> <log:warn>${issue.key} : ${issue.reporter.displayName}</log:warn> </core:forEach>
and whilst the issue key appears in the log files, the reporter name does not. (Note: Using ${issue.reporter} prints the username of the reporter, though.)
Hope this helps and thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How about this?
<core:forEach var="issue" items="${issues}"> <core:invoke on="${issue}" method="getReporter" var="reporter"/> <log:warn>${issue.key} : ${reporter.displayName}</log:warn> </core:forEach>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for this but unfortunately it threw:
Could not run script.
Extra Information: [hide]
when I ran it in Jelly Runner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah wait, is $issue a Issue object? Looks like it is a GenericValue. You will have to get the Issue object before doing this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh right, how do I get the Issue object? I assume that it involves some kind of invokation and needs to be placed inside that iterator?
I tried implementing the IssueObject as per this suggestion but Jelly Runner threw an exception about the IssueManager.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe something like this:
<core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getIssueManager" var="issueManager"/> <core:forEach var="issue" items="${issues}"> <core:invoke on="${issueManager}" method="getIssueObject" var="issueObj"> <core:arg type="java.lang.String" value="${issue.key}"/> </core:invoke> <core:invoke on="${issueObj}" method="getReporter" var="reporter"/> <log:warn>${issue.key} : ${reporter.displayName}</log:warn> </core:forEach>
UNTESTED
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have noticed that
${issue.reporter}
works by returning the reporter's username but
$(issue.reporter.displayname}
doesn't return anything, nor does
${issue.reporter.fullname}
I feel that this is the right line to go down but can't be sure.
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.