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

1 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

708 views 6 13
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