If I have a YAML Pipeline;
variables:
- name : myVariable
value : 'abcd'
and if I want to run some inline powershell - how can i access that value (abcd) in the powershell script;
I expected this to work - but it didnt;
- task: PowerShell@2
displayName: "Do the thing"
inputs:
targetType: 'inline'
script:
write-host $(myVariable)
we could refer to this doc to specify variables at the pipeline, stage, or job level.
YAML build definition:
pool:
vmImage: 'vs2017-win2016'
variables:
- name : myVariable
value : 'abcd'
steps:
- task: PowerShell@2
displayName: "Do the thing"
inputs:
targetType: 'inline'
script:
write-host $(myVariable)
Result:

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