Is the simplest way to include all mathine's name in email notification?

Hi, I do some research to add the target machine name in the success/fail email notification, and success by below way. I think it’s simplest way I can found so far.

  1. add a step template call "SetMachineName"
    with powerShell like:
    $MachineName =$OctopusParameters[“Octopus.Machine.Name”]
    Set-OctopusVariable -name “MachineName” -value $MachineName

  2. in email notification Template add

    #{each machine in Octopus.Action[SetMachineName].Output}
  • #{machine} or #{machine.MachineName}
  • #{/each}

It works for me for multiple machines.
ref: https://octopus.com/docs/deploying-applications/variables/output-variables

Hi,

Thanks for reaching out. That does sound like a simple approach. If its getting you the desired end result, I’d say that’s ok :slight_smile:

Cheers,
Dalmiro

Hi,

I have an Octopus job which has 5 deployment process steps. Each step has a different role, in other words,

  1. step1 runs on 1, 2, 3 servers
  2. step2 and step 3 runs on 4, 5 servers
  3. step 4,5 runs on 6, 7 servers.

Sometimes we simply disable few steps while performing the deployment. in other words, I will/may execute only steps 1, 2, 3 and not 4,5. For this kind of scenarios’, how can i get the list of the machine names for various executed steps and use them in my email step.

I want to clearly mention in my email saying that step#1 is ran on 1,2,3 servers and step#2 ran on 3, 4 and 5 servers etc.

Please suggest me the possible solution how can i achive this. Thanks in advance.

Hi,

This isn’t something supported out of the box, but i’ve spent quite some time trying to find a workaround and I think I did:

  1. Open the below gist and create a script module with the code on ScriptModule.ps1. Then import that script module from your project

Gist: https://gist.github.com/Dalmirog/1cb4e89cb3b146dad5c6785073a58984

How to create and import a script module: https://octopus.com/docs/administration/script-modules

  1. Add an email step at the end of your deployment process with the code on email.txt on the below gist

Let me know how that goes,
Dalmiro