0

I'm attempting to create a new build pipeline which will run nearly identical steps for a release branch and the master branch. I also want to allow overriding the pipeline's build style (release vs master branch) using the queue time variables.

Here's the variable defined:

1]

When I set variable at queue time, the values are calculated:

2]

And the queue time variables are found:

3]

But when I go to access the value with this:

4]

The value is false:

5]

Am I doing something wrong or expecting queue time variables to function differently than their designed? I thought they overrode the original values defined in the pipeline.

Stevoni
  • 341
  • 7
  • 18

1 Answers1

0

I thought they overrode the original values defined in the pipeline.

Yes, the original variables values got overrode at the queue time.

According to the imgs you showed, the IsProductionRelease is calculated as 'False' which is also generated in your powershell script, this means your queue time variable is working correctly, the only different part is in your third img it changes to 'true' for some reason.

I built a demo you can refer to:

The SourceBranch is set to the master branch:

enter image description here

Variable IsProductionRelease:

enter image description here

In the first test, the variable value was not changed:

Variables:
  IsProductionRelease:
    Parsing expression: <startsWith(variables['Build.SourceBranch'],'refs/heads/release')>
    Evaluating: startsWith(variables['Build.SourceBranch'], 'refs/heads/release')
    Expanded: startsWith('refs/heads/master', 'refs/heads/release')
    Result: 'False'

And the powershell returns 'False' value too:

Is Producetion Release = False

In the second test, change the IsProductionRelease value to $[startsWith(variables['Build.SourceBranch'],'refs/heads/master')]:

enter image description here

Calculated result:

Variables:
  IsProductionRelease:
    Parsing expression: <startsWith(variables['Build.SourceBranch'],'refs/heads/master')>
    Evaluating: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
    Expanded: startsWith('refs/heads/master', 'refs/heads/master')
    Result: 'True'

And the powershell returns 'True'

Is Producetion Release = True

Please check your whole process again.

Yang Shen - MSFT
  • 1,136
  • 1
  • 7
  • 9
  • Thanks for the helpful response. Why can I not just set the queue time value to true instead of requiring an expression? – Stevoni Feb 11 '20 at 19:46
  • Now i understand how you generate your third img, you change the expression to a specific text value 'true' at the queue time. I tested it too and reproduced the issue. Seems in the `Job preparation parameters` part the variable was set to expression calculation value that can not be overrode by a text value. I sugggest you should quit the expression set a 'false'/'true' text value to your `IsProductionRelease` if you want to change the value directly without expression calculation. – Yang Shen - MSFT Feb 12 '20 at 01:30
  • Thanks for following up, I'm probably going to file a bug report then. – Stevoni Feb 12 '20 at 06:28
  • Good idea, you might get a better understanding even it might not accepted as a bug. Best regards. – Yang Shen - MSFT Feb 12 '20 at 06:50