Get variable value from the next deployment target

Hi, I am trying to find a way to get the server name of the next deployment target. Let’s say I am in a QA scope, and I want to have the deployment target name (dns) of the Production scope.
What we are trying to do is make a backup from production and restore it in our QA environment and we do not want to hardcode the server path.


Hi @clau.laplante90,

Thanks for getting in touch! Based on what you’ve described it looks like this would require going via the API route to grab this information. The following sample script is the closest I’ve found which will return the names and URI of machines in a given environment and role.

I think the only modification to the script for your scenario would be to change the environment ID to match the production environment (as it currently calls a system variable to grab the target environment).

Alternatively, you might be able to make use of the system variable Octopus.Environment.MachinesInRole[\_role\_] but that will just return machine IDs so I’m not sure if that’ll be helpful in any way.

Let me know how you go or if I’ve misunderstood anything in any way. :slight_smile:

Best regards,


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