Modify release notes template

Hi all,

 

I've created a new release notes template following this KB: https://confluence.atlassian.com/display/JIRA041/Creating+a+Custom+Release+Notes+Template+Containing+Release+Comments

 

But, I want my new template to only apply to one project. Does anyone know what the proper syntax would be for the "if statement" if I want to start my template with:

#if project = myproject

...my new template

 

#else

the out of the box template

 

#end

 

 

1 answer

1 accepted

This widget could not be displayed.

If "$issues" contain the issues, to be included, then you could the first one and check its container project's key:

#if($issues.get(0).projectObject.key == "WHATEVER")
... in the "WHATEVER" project
#else
... in some other project
#end

Thanks Aron! It's still not quite working for me. Here's what I did. My goal is that in the ABC project, I don't see the issue key and summary (only the custom field) but that in all my other projects I see the usual stuff for release notes.

 

But when I use this, it is removing the key/summary in all projects. Am I missing something?

 

#foreach ($issueType in $issueTypes)
#if($issueType.issues.size() > 0)
** $textUtils.htmlEncode($issueType.name)
#foreach ($issue in $issueType.issues)
#if($issues.get(0).projectObject.key == "ABC")
* #getReleaseNoteComment($issue $customFieldManager)
#else
* [$issue.key] - $textUtils.htmlEncode($issue.summary)#getReleaseNotes($issue $customFieldManager)
#end
#end
#end
#end

Looking at your code, I think this line:

#if($issues.get(0).projectObject.key == "ABC")

should rather be:

#if($issue.projectObject.key == "ABC") 

Thank you! I was able to get it to work. For posterity, here's my complete code if anyone else ever wants it. What it does is for project ABC, only show a custom field called RNotes, and for everyone else it keeps the template the same as the out of the box. There is a minor bug that if the custom field is empty, it will display a blank bullet point, but someone could probably figure that out.

 

Html:

#macro (getReleaseNoteComment $issue $customFieldManager)
#set ($customFields = $customFieldManager.getCustomFieldObjects($issue.project.getLong("id"), $issue.issueType.getString("id")))
#foreach($customField in $customFields)
#if($customField.name.equals("RNotes"))
#if($customField.getValue($issue) != '') $textUtils.htmlEncode($customField.getValue($issue))#end
#end
#end
#end

#disable_html_escaping()
##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

<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)
   #if($issue.projectObject.key == 'ABC')
   <li> #getReleaseNoteComment($issue $customFieldManager)</li>
   #else
            <li>[<a href='$requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($issue.summary) </li>
   #end
  #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)
#if($issue.projectObject.key == 'ABC')
<li>#getReleaseNoteComment($issue $customFieldManager)</li>
#else
<li>[<a href='$!requestContext.canonicalBaseUrl/browse/$issue.key'>$issue.key</a>] - #doubleEncode($issue.summary) </li>
#end
#end
</ul>
#end
#end
</textarea>

</body>

 

 

Text template:

 

#macro (getReleaseNoteComment $issue $customFieldManager)
#set ($customFields = $customFieldManager.getCustomFieldObjects($issue.project.getLong("id"), $issue.issueType.getString("id")))
#foreach($customField in $customFields)
#if($customField.name.equals("RNotes"))
#if($customField.getValue($issue))$textUtils.htmlEncode($customField.getValue($issue))#end
#end
#end
#end

#disable_html_escaping()
<title>$textUtils.htmlEncode($action.getText('release.notes.text.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)
            #if($issue.projectObject.key == 'ABC')
   <li>#getReleaseNoteComment($issue $customFieldManager)</li>
   #else
   <li>[<a href='$!requestContext.baseUrl/browse/$issue.key'>$issue.key</a>] - $textUtils.htmlEncode($issue.summary)</li>
   #end
        #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">

$action.getText('release.notes.heading', $project, $version)
#foreach ($issueType in $issueTypes)
#if($issueType.issues.size() > 0)
** $textUtils.htmlEncode($issueType.name)
#foreach ($issue in $issueType.issues)
#if($issue.projectObject.key == 'ABC')
* #getReleaseNoteComment($issue $customFieldManager)
#else
* [$issue.key] - $textUtils.htmlEncode($issue.summary)
#end
#end
#end
#end
</textarea>

</body>

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

220 views 3 0
Join discussion

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