Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify release notes template

Brandon Kreiens January 5, 2018

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
Answer accepted
Aron Gombas _Midori_
Community Champion
January 7, 2018

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
Brandon Kreiens January 8, 2018

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

Aron Gombas _Midori_
Community Champion
January 14, 2018

Looking at your code, I think this line:

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

should rather be:

#if($issue.projectObject.key == "ABC") 
Brandon Kreiens January 22, 2018

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>

Like Sana Safai likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events