I have a pipeline decorator:
steps:
- task: CmdLine@2
displayName: 'Decorator-injected Task'
inputs:
script: echo This is from the Decorator for Build
- ${{ if eq(variables['injectDecorator'], 'true') }}:
- task: CmdLine@2
displayName: 'Decorator-injected Task'
inputs:
script: echo Trying to get the conditional to work
- task: PowerShell@2
displayName: 'Run my script (injected from decorator)'
inputs:
targetType: 'inline'
script: |
write-host "Hello from my pipeline decorator"
# - pwsh: |
# write-host "this will not fire"
If I uncomment the last two lines none of the decorator will fire. I'd like to understand why including the pwsh command breaks the whole decorator?
Because 'pwsh' ≠ 'Powershell Task', pwsh is just a shortcut, I think you know what is the different between 'shortcut' and 'the object actually responsible for the execution'.
pwsh equivalent to passing an inline script to the PowerShell task. Parser does this under the covers - transforms pwsh into task: PowerShell@2 with input targetType: inline. They are not the same, their relationship is like the 'shortcut' icon you see on the desktop of the Windows system and the '.exe executable file' in the root directory of the software installation.
So please use the original Task: PowerShell@2