Deployment selecting wrong variables on deployment

Octopus 3.15.6

I have a variable set that uses roles and environments to select the correct variables for the instance. However, it appears that the role is being ignored and that only the environment is being used to select the variables. This means that the FIRST matching variable by environment is being selected - meaning the wrong variable is used.

I understand from https://octopus.com/docs/deploying-applications/variables/scoping-variables that the role should be given more priority (https://octopus.com/blog/variable-specificity-and-complexity) however, this does not appear to be working. Only the environment is selected.

Is it possible to see (logs, console output etc…) how Octopus is selecting the variables to use? Any other advice?

Hi Peter,

Thanks for getting in touch! Check out our variable debugging documentation, that may help to narrow it down, particularly the last section (print to log).

If you can’t figure out why it is selecting the wrong variables, could you send me:

  • a screenshot of the variable in question in the variable editor showing the scoping
  • a screenshot of the deployment target in question
  • a screenshot of the deployment step
  • output related to that variable from the log (with variable logging enabled)
  • if possible a full task log

Hope that helps!

Robert W

Attached is a file with the data requested.

OctopusProblem.zip (1 MB)

Hi Peter,

Thanks for that. If a variable matches a machine on two roles, that does not make it of a higher precedence than if it just matched on one role. See the bottom of this for the reasoning behind this (except it doesn’t explicitly state this).

So in your case, your machine has Roles nxlog and service-mail-web-1. The first two RELAY_NAME variables would match at an equal priority (Role and Environment, giving a score of 10010), so it picks the first one.

Looking at the variable you have provided, I think you can safely drop the nxlog scope.

Another thing to note is that if, for example, a step is scoped to nxlog, it will run on all machines with the nxlog role. However, the step scope is not taken into account when working out the variables for that step and machine, so a variable just scoped to service-mail-web-1 could be used for that particular step.

Hope that makes sense.

Robert W