Variable substitution in Release Notes Template

When I use this syntax:
#{if package.PackageId | Match ReleaseInfo}


Or this one:
#{if package.PackageId | Substring 11 == “ReleaseInfo”}


Instead of this one:
#{if package.PackageId == “ReleaseInfoExactName”}


Release notes generation during release creation stops working.

Can you tell me what’s wrong with my code?

Octopus Server v2021.1.7316

I just found in the documentation this info:
“Using variable filters inline in the two conditional statements if and unless are not supported .”

Is this the case? Maybe I don’t understand it, but just below this warning, there’s example of actually working variable filter inline in conditional statement.

#{if Octopus.Release.Number | VersionPreReleasePrefix == “mybranch”}true#{/if}

Source: Variable substitutions - Octopus Deploy

Here’s my full release notes template:

#{each package in Octopus.Release.Package}
  #{if package.PackageId | Substring 11 == "ReleaseInfo"}
- #{package.PackageId | Substring 11}
    #{each commit in package.Commits}
      #{if commit.CommitId}
  - [#{commit.CommitId}](#{commit.LinkUrl}): #{commit.Comment}
        #{if Octopus.Template.Each.First}
          #{if Octopus.Template.Each.Last}
  - no changes

The problem is 2nd line, mentioned in original post.

Hi @rafal.gapski

Your assumption is correct -inline variable filters using if and unless are not supported.

The documentation you reference about the working condition actually follows with this text:

However, the evaluation of the statement would always return False as the syntax is not supported.

This example was added to highlight the problem more clearly.

I’d recommend trying the workaround listed e.g. using a project variable with the inline filter instead:

Variable name: PackageIdSubstringValue with a value:

package.PackageId | Substring 11

With a condition like this:

#{if PackageIdSubstringValue == "ReleaseInfo"}

I hope that helps!

That works, thank you

Hi @rafal.gapski

That’s great to hear, thanks for letting me know!


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.