Email Notifications

I have an email notification step that generates an email when a deployment is completed. The below HTML spits out too much info. It includes all the steps even if they are excluded. What is the best way to have this only provide the steps that were completed and does not include any steps that were excluded in the deployment? Thanks!

	<h2>Deployment of #{Octopus.Project.Name} #{Octopus.Release.Number} to #{Octopus.Environment.Name}</h2>
    <p><em>Initiated by #{unless Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.Username}#{/unless} #{if Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.DisplayName}#{/if} #{if Octopus.Deployment.CreatedBy.EmailAddress} (<a href="mailto:%20#{Octopus.Deployment.CreatedBy.EmailAddress}">#{Octopus.Deployment.CreatedBy.EmailAddress}</a>)#{/if} at #{Octopus.Deployment.Created}</em><br>

    <h3>Deployment process</h3>
    <p>The deployment included the following actions:</p>
    <ul>
        <li style="list-style: none">#{each action in Octopus.Action}</li>
        <li><strong>#{action.Name}</strong> #{if action.Package.NuGetPackageId}&mdash; {action.Package.NuGetPackageId} <em>version #{action.Package.NuGetPackageVersion}#{/if}</em></li>
        <li style="list-style: none">#{/each}</li>
    </ul>

Hi @Hank-Scorpio !

Thanks for reaching out, and for the great question. Thankfully, this is a relatively easy to do. You can operate on action.IsSkipped (Octopus.Action.IsSkipped is the boolean variable) here to only operate on steps that actively ran.

For more information, please be sure to check out our System Variable page here: System variables - Octopus Deploy

Thanks for the feedback. So would I be looking at adding this to the code?

	<h2>Deployment of #{Octopus.Project.Name} to #{Octopus.Environment.Name}</h2>
    <p><em>Initiated by #{unless Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.Username}#{/unless} #{if Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.DisplayName}#{/if} #{if Octopus.Deployment.CreatedBy.EmailAddress} (<a href="mailto:%20#{Octopus.Deployment.CreatedBy.EmailAddress}">#{Octopus.Deployment.CreatedBy.EmailAddress}</a>)#{/if} at #{Octopus.Deployment.Created}</em><br>

    <h3>Deployment process</h3>
    <p>The deployment included the following actions:</p>
    <ul>
	    <li style="list-style: none">#{each action in Octopus.Action} #{unless Octopus.Action.IsSkipped}</li>
	    <li><strong>#{action.Name}</strong> #{if action.Package.NuGetPackageId}&mdash; {action.Package.NuGetPackageId} <em>version #{action.Package.NuGetPackageVersion}#{/if}</em> </li>
	    <li style="list-style: none">#{/each}</li>
    </ul>

Hi @Hank-Scorpio

You’d likely want to use logic something along the lines of:

    <h3>Deployment process</h3>
    <p>The deployment included the following actions:</p>
    <ul>
        <li style="list-style: none">#{each action in Octopus.Action}</li>
        #{if action.IsSkipped == "False}<li><strong>#{action.Name}</strong> #{if action.Package.NuGetPackageId}&mdash; {action.Package.NuGetPackageId} <em>version #{action.Package.NuGetPackageVersion}#{/if}</em></li>#{/if}
        <li style="list-style: none">#{/each}</li>
    </ul>

Naturally, will likely require some tweaks, but it should hopefully get you heading in the right direction.

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