Variable Scoping Issue


We believe we may have found an issue with variable scoping. After looking through the docs on how the scoping should work what we’re seeing doesn’t make sense (however we could be wrong).

We have a variable defined only at the project level that should be specific to a couple of environments (INT, UAT) and a couple of machines in another environment (CUIAPP005, CUIAPP006 in CUI). There is then second a fall back variable (unscoped) to cover everything else. This works correctly for the INT and UAT environments but not the specific machines in CUI.

We have worked out that we can fix the issue by included the CUI environment in the variable scoped to the machine however this seems wrong as anyone looking at this setup would assume it applies to all of CUI.

This should be possible to see more clearly in the attached screen shot.


Hi Dave,
I believe the issue you are having would be resolved by creating a new variable scoped to just the machines in the other environment. This is because variable scoping follows a progressively stricter approach, which means that different scopes are ANDed together rather than ORed.
Based on your configuration the OldCompareToNew value would only be used in the deployment condition of:
( (Integration OR UAT) AND (CUAPP005 OR CUAPP006))

What you should instead do is add a new variable scoped to just CUAPP05 and CUAPP06 (and CUI if you only want it to go to those machines when its for that environment).

If you wanted to then ensure the same value is used for both scoped scenarios you could then create a new variable, lets say MySharedValue and then reference it in the 2 scoped variables as #{MySharedValue}

Let me know if this makes sense or if you require any further clarification on the topic of variable scoping.