3
votes

Problem:

I've got a manual intervention step with textual steps for the person performing the deployment to follow.

I'd like to pass in the name of the target server so the the person doesn't need to lookup the server name being targeted.

For example as you see below, I need them to unzip to a location on the target server.

**SECTION 1: (Main installation)**
1. Navigate to: #{InstallationZipLocation}.
2. Download zip file named: #{ZipFileName}
3. Unzip to the desktop on: #{DeploymentTargetMachineName}  --need help here
4. Run executable named: #{ExecutableName}
5. Accept default settings

What I have tried:

Octopus Deploy - System Variables Documentation offers:

enter image description here

#{Octopus.Deployment.Machines} results in: Machines-6

#{Octopus.Deployment.SpecificMachines} results in: (empty string)


What I expect to see:

3. Unzip to the desktop on: FTPServer05

Additional Comment: I realize I could set the name of the target server in my variables list for each target environment/scope, resulting in only 4 variables (not a big deal, and easy to maintain), but I was curious if there was a way to simplify it. We are running Octopus Deploy 3.12.9.

1

1 Answers

3
votes

So I was looking for an easier approach, but stumbled on something that I found to be rather interesting so I went ahead and implemented it.

Output variables. . . "After a step runs, Octopus captures the output variables, and keeps them for use in subsequent steps."


What I did to resolve my issue:

I setup a custom step-template which sole purpose is to set "output variables" to use in my subsequent step. You could have this be your first step in your project, or at a minimum come before the step that references the variable you are setting.

Custom step setup:

Powershell:

Write-Host "TargetDeploymentMachineName        $TargetDeploymentMachineName"
Set-OctopusVariable -name "TargetDeploymentMachineName" -value $TargetDeploymentMachineName

Parameters: enter image description here

Then in my Manual Intervention step, I use the output value like so:

3. Unzip to the desktop on: #{Octopus.Action[MyProject-Set-Output-Variables].Output.TargetDeploymentMachineName}

(Where [MyProject-Set-Output-Variables] represents the name of the step in my deployment project which is responsible for assigning the output variables)


Explanation for why I was having trouble in my question:

Turns out the variable binding syntax to use for my question would have been:

Octopus.Machine.Name = The name that was used to register the machine in Octopus. Not the same as Hostname

However, the Manual Intervention step specifically does not have a "Deployment Target":

enter image description here

It instead just runs on "Octopus Server":

enter image description here

So I am pretty sure that is why I was not getting a value for the "target". For example, I simply tested another new basic step that used the "Deployment Targets" radio buttons, which resulted in the FTPServer05 value I was expecting.