Getting linked issues when creating release notes

James Wong July 15, 2013

Is it possible to get the linked issues when creating release notes?

4 answers

1 accepted

3 votes
Answer accepted
Justin Alex Paramanandan
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 15, 2013

Hi James,

Yes, it is indeed possible to grab the linked issues when generating releases notes. Below is a sample code I used in the $JIRA_INSTALL/atlassian-jira/WEB-INF/classes/templates/jira/project/releasenotes/releasenotes-html.vm:

##Text is escaped twice so that the characters generated in the text area display properly escaped (JRA-12184)
###macro (doubleEncode $html)
## $textUtils.htmlEncode($textUtils.htmlEncode($html))
###end

#set ($componentManagerClass = $constantsManager.getClass().getClassLoader().findClass('com.atlassian.jira.ComponentManager'))
#set ($issueLinkTypeManagerClass = $constantsManager.getClass().getClassLoader().findClass('com.atlassian.jira.issue.link.IssueLinkTypeManager'))
#set ($method = $componentManagerClass.getDeclaredMethod('getInstance', null))
#set ($componentManager = $method.invoke(null, null))
#set ($issueLinkManager = $componentManager.getIssueLinkManager())
#set ($issueLinkTypeManager = $componentManager.getComponentInstanceOfType($issueLinkTypeManagerClass))

<title>$textUtils.htmlEncode($action.getText('release.notes.html.title', $project, $version))</title>
<body>

<div class="ops-cont">
<ul class="ops">
<li>
<a class="button first last" href="$!requestContext.baseUrl/secure/ConfigureReleaseNote.jspa?projectId=${versionObj.projectObject.id}&amp;version=${versionObj.id}">$action.getText('releasenotes.configure')</a>
</li>
</ul>
</div>

#foreach ($issueType in $issueTypes)
#if($issueType.issues.size() > 0)
<h2>$textUtils.htmlEncode($issueType.name)</h2>
<ul>
#foreach ($issue in $issueType.issues)
<li>[<a href='$requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($issue.summary)
<ul>
#foreach($linkedIssue in $issueLinkManager.getLinkCollectionOverrideSecurity($issue).getAllIssues())
<li>Linked Issue: [<a href='$requestContext.canonicalBaseUrl/browse/$linkedIssue.key'>$linkedIssue.key</a>] - $textUtils.htmlEncode($linkedIssue.summary)</li>
#end
</ul></li>
#end
</ul>
#end
#end


<a name="editarea"></a>
<h2>$action.getText('release.notes.edit.copy')</h2>
<p>$action.getText('release.notes.description')</p>

<textarea rows="40" cols="120" id="editcopy">

#doubleEncode($action.getText('release.notes.heading', $project, $version))
#foreach ($issueType in $issueTypes)
#if($issueType.issues.size() > 0)

<h2>#doubleEncode($issueType.name)</h2>
<ul>
#foreach ($issue in $issueType.issues)
<li>[<a href='$!requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - #doubleEncode($issue.summary)</li>
#end
</ul>
#end
#end
</textarea>

</body>

There is a pointer that needs to be pointed out:

  • Do note the importance of the #set lines above. This is like a declaration for setting the issueLinkManager class.

The formatting is a bit rough, but it works. Here's a screenshot of the release notes:

I believe that for text versions of release notes, the method may be similar; I've just tried this with HTML. Hope this helps!

 

James Wong July 17, 2013

wow works like a charm. 1000x thanks @Justin Alex.

Justin Alex Paramanandan
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 17, 2013

You're welcome, @James! Glad that it worked for you. :)

Antoin Stanton March 1, 2016

I have tried using this and I am getting an error saying:

 

org.apache.velocity.exception.MethodInvocationException: Invocation of method 'findClass' in class org.apache.catalina.loader.WebappClassLoader threw exception java.lang.LinkageError: loader (instance of org/apache/catalina/loader/WebappClassLoader): attempted duplicate class definition for name: "com/atlassian/jira/ComponentManager" at templates/jira/project/releasenotes/test-release.vm[line 1, column 78]

 

I realise my file is not loacted in the JIRA_INSTALL directory, but it is actually resourced from this directory, so in effect, it is located there.

Oskar Hołowacz February 15, 2019

Hi Justin Alex Paramanandan [ServiceRocket], 

I have been trying to attach linked issues to my release notes template (html) using your code - unfortunately something is not right - by that i mean that in this piece of code i can see in the developer tools first foreach is doing his job and created an unordered list - unfortunately this list is empty which is due to i think one thing  - this object is empty or this function return null - ( i have in many task - linked issues so it should return a few values)  $issueLinkManager.getLinkCollectionOverrideSecurity($issue).getAllIssues() 

Could You help with this or at least point how to debug/check this please ( doing the changes the each time restarting the jira is very time-consuming)

#foreach ($issue in $issueType.issues)
<li>[<a href='$requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($issue.summary)
<ul>
#foreach($linkedIssue in $issueLinkManager.getLinkCollectionOverrideSecurity($issue).getAllIssues())
<li>Linked Issue: [<a href='$requestContext.canonicalBaseUrl/browse/$linkedIssue.key'>$linkedIssue.key</a>] - $textUtils.htmlEncode($linkedIssue.summary)</li>
#end
</ul></li>

  Thanks

jkirali February 25, 2019

Hi there,

i´m facing the same problem.  :-/

Sveinn Zoega June 25, 2019

 

I had the same problem on version 7.11, reading the javadocs for ComponentManager I noticed:

Deprecated. since 7.11 use ComponentAccessor instead (or inject dependencies where possible)

 

I changed the #set lines to:

#set ($componentAccessorClass = $constantsManager.getClass().getClassLoader().findClass('com.atlassian.jira.component.ComponentAccessor'))
#set ($method = $componentAccessorClass.getDeclaredMethod('getIssueLinkManager', null))
#set ($issueLinkManager = $method.invoke(null, null))

 

Then it all works fine

 

Like jkirali likes this
jkirali July 8, 2019

@Sveinn Zoega thanks, that one helped!

Like Sveinn Zoega likes this
0 votes
Midori
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.
February 11, 2014

Use the JIRA PDF View Plugin to define the business logic behind your Release Notes documents.

It can execute Groovy scripts that can traverse and collect the linked issues and possibly do anything else by having full access to JIRA's internals.

See this example

0 votes
mwarton
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.
January 22, 2014

For those interested, a much simpler way to get customised release notes, which can include linked issues amongst many other things, is to install the plugin Intelligent Reports.

You can design your release notes template in Microsoft Word, then use simple but powerful point and click rules to choose the data, issues and fields you want filled in to the release notes. No scripting, programming, API or modifying JIRA internals.

0 votes
Shelli January 20, 2014

Hi,

I copied the sample code above to my releasenotes directory as noted above, restarted JIRA and created release notes for a version with linked issues. The linked issues did not show up for me and I think it may be because the linked issues belong to a different project.

Can somebody confirm that this is correct? Is there a way to include linked issues from another project?

Thanks!

James Wong January 21, 2014

Hi Shelli,

In my case my issues are linked to a multitude of different projects (since we use 1 'project' to track progress of all other projects) and we have no problem. I suppose you are doing this as the super admin so permission shouldn't be a problem.

Shelli January 21, 2014

Yes we use what we call "umbrella" projects to which others are related and we'd like to get the release notes for all the related projects/issues from the umbrella's project issues.

What do you mean by "super admin"? My user profile has the "jira-administrators" role, but I don't see how that impacts changing the template in the deployment directory.

James Wong January 22, 2014

Hi there,

Sounds like we have similar set ups. By super admin, i mean if you had all the priviledges/ permissions activated for your account.

The only thing i can tell you is, try to go back to Justin's post and do it all over again. It worked for me twice, once on Windows and after we migrated to CentOS. And restart JIRA afterwards, to be on the safe side.

Suggest an answer

Log in or Sign up to answer