Getting linked issues when creating release notes

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

4 answers

1 accepted

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!

 

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

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

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.

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!

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.

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.

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.

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.

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
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,721 views 17 21
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you