It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting linked issues when creating release notes

James Wong Jul 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 [ServiceRocket] Jul 15, 2013 • edited Sep 16, 2018

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 Jul 17, 2013

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

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

Antoin Stanton Mar 01, 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 Holowacz Feb 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 Feb 25, 2019

Hi there,

i´m facing the same problem.  :-/

0 votes
Shelli Jan 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 Jan 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 Jan 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 Jan 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.

0 votes
mwarton Jan 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
Ferenc Kiss [Midori] Feb 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

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

1,944 views 3 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you