Use tentacle IP on a script that executes on octopus server

Have a script step that executes on octopus server (rather than on tentacle). The script executes a software installed on octopus server, and the software needs tentacle’s ip as a parameter.

Is it possible to access tentacle ip from pshell.

Hi,

Thanks for getting in touch. You can’t do this directly, however you can run a seperate script step first that executes on the tentacle and gets its IP and sets it to an output variable and then use that value in your script step that runs on the server.

So your setup would be:
1. Create a script step called “Get IP” that runs on “Deployment targets” and pick the appropriate roles. You PowerShell script body would be:

$ipV4 = Test-Connection -ComputerName (hostname) -Count 1  | Select IPV4Address
Set-OctopusVariable -name "IPV4Address" -value $ipV4.IPV4Address

2. In script step that runs on Octopus Server make sure you pick the same roles, the you can access the Output Variable with (in PowerShell)

$ipaddress = $OctopusParameters["Octopus.Action[Get IP].Output.IPV4Address"]
Write-Host "The machine's IP is" $ipaddress

If you have multiple Machines in your target Role, Octopus is smart enough to scope the output variable to the appriopriate machine.

I hope that helps.

Mark

Helps??? You bet, it saved me from reshaping a whole development process into migration scripts.

Best answer to any question ever asked.