I am trying to reference a task in an external yaml file and run it if debug mode is on (system diagnostics checkbox selected, which makes system.debug=true).
I tried the following lines of code:
- ${{ if eq(variables['system.debug'],true) }}:
- template: ./steps/devops/print-directory.yaml
parameters:
displayName: "[Debug] List Pipeline Workspace files"
folder: $(Pipeline.Workspace)
Somehow the system.debug variable is emptied before it enters that condition, and so the task is not exhibited during pipeline execution.
Is there a way of keeping the value of system.debug variable so that it enters the condition? Is there another way to access this variable, or address this problem ?
I've tried to declare a variable called system.debug in the pipeline:
variables:
- name: system.debug
value: true
And in this case, the task was correctly exhibited in the pipeline execution, which proves that the system variable is emptied at some point of the pipeline !
This is not possible. ${{ }} is a compile-time expression and system.debug is set at runtime.
Take a look here on Developer Community
Runtime variables cannot be referenced from template expressions (inside
${{ }}). Only variables defined within the YAML can be used there. This is not a behavior change. Runtime variables likesystem.debugcan be used in expressions within the condition attribute of step however.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With