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}&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:
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome, @James! Glad that it worked for you. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.