ossentoo
ossentoo

Reputation: 2019

Azure DevOps variable is unexpected set to Null

I've got a pipeline with multiple jobs. For some reason, a variable that is set the stage is Null in a condition that is running from a job.

Here's the pipeline yaml:

https://github.com/ossentoo/azdo-yaml-varsdemo/tree/feature/private-agent

The syntax that i'm not expecting to evalutate to false is in the child.yml (line 24):

child yaml

I've attached one of the files from the log from Azure DevOps logs

In the log on line 73, this is shown:

Logs

The question is, why is variable applicationsList Null if the value is being set in the stage? I have tried changing syntax to variables.applicationsList, but that doesn't appear to work either.

thanks

thanks

Upvotes: 0

Views: 1394

Answers (1)

jessehouwing
jessehouwing

Reputation: 114461

The problem is that the ${{ ... }} syntax is evaluated at compile time. At that point in time the value is still undefined.

Instead, you can use condition: $[ ... ]. That syntax will be evaluated at runtime.

See:

- ${{ each folder in parameters.folders }}:
  - deployment: ${{replace( folder ,'-','_')}}
    displayName: 'Apply ${{ folder }}'
    timeoutInMinutes: 480
    condition: $[contains(variables['applicationsList'], ${{folder}})]

Upvotes: 1

Related Questions