Variable Set and Target Roles behavior

Hi,

I noticed an odd behavior with “Variable Set”.

We need to have variable with multiple values shared across different projects.

I have:

  • “Dev Environment” with target server “Engine server” with two roles “Engine” and “Manager”
  • Two packages to deploy “EnginePkg” and “ManagerPkg”
  • “Dev Project” with two steps:
    “Engine” with “Engine” role for “EnginePkg”
    “Manager” with “Manager” role fro “ManagerPkg”
    Each step have custom installation folder initialize with the #{InstallFolder}
  • Variable set with one variable with multiple values associated with the “Dev Project”
    Name of the variable: “InstallFolder”
    C:\Program Files\Factory#{Octopus.Step.Name} Environment Scope: “Dev Environment”, nothing else
    C:\Apps\Factory#{Octopus.Step.Name} Environment Scope: “Dev Environment”, Target Roles: “Engine”

What I expected when I deployed the release was:
C:\Program Files\Factory\Manager
C:\Apps\Factory\Engine

But the packages were deployed on
C:\Program Files\Factory\Manager
C:\Program Files\Factory\Engine

Did I miss something? :slight_smile:

I used 2018.2.5 and 2.6.4 and I have the same behavior.

Regards,
Stéphane

Hi Stephane

Thanks for getting in touch! This is actually a very good question.

Variables can be scoped to multiple values, so deciding which value a variable is evaluated to in a given scenario can be a surprisingly tricky process. We call it variable specificity. You can get more information about it from here https://octopus.com/blog/variable-specificity-and-complexity

In a high level view, Octopus will choose the more specific one for a variable with multiple scopes, which is the one scoped with DEV and Engine in your scenario.

In order to use different values for both steps, I would suggest to consider one of the options below

  • Scope both values with Environment and Role, e.g one scoped to DEV and Engine, and the other scoped to DEV and Manager
  • Scope both values with role only, e.g. one with Engine and the other one with Manager

I hope this helps! Let me know what you think and how you go.

Regards
Eddy

Hi Eddy,

Thanks for the information.
I use the first option and it now works as expected.

Have a good day.
Stéphane

Hi Stephane

I am glad that you managed to get it working.

Please do not hesitate to contact us if you have any other queries.

Happy deployment!

Eddy

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