I have a Azure pipeline containing a job with a structure like this:
jobs:
- job: A
variables:
- name: runJob
value: true
steps:
- task: Powershell@2
displayName: Evaluate runJob
inputs:
targetType: inline
script: |
<do some processing>
echo "##vso[task.setvariable variable=runJob; isOutput=true]false"
echo "##vso[task.setvariable variable=runJob]false"
echo "New value for runJob: $(runJob)"
- ${{ if eq(variables['runJob'], 'true') }}
- checkout: self
- execute remaining steps below ...
I'm able to execute the whole pipeline with runJob as 'true' but when the required conditions are met, the value of runJob should have been set as false using task.setVariable which is not happening. I tried with both ways with and without isOutput=true but the value of the variable still remains true and the pipeline is executing the remaining steps.
I need to update the variable value and want it to access the variable value as part of the condition.
jobs:
- job: A
variables:
- name: runJob
value: True
steps:
- task: Powershell@2
name: step1
displayName: Evaluate runJob
inputs:
targetType: inline
script: |
Write-Host "##vso[task.setvariable variable=runJob; isOutput=true]False"
Write-Host "New value for runJob: $(runJob)"
- task: PowerShell@2
name: step2
displayName: Next display
condition: eq(variables['runJob'], 'False')
inputs:
targetType: inline
script: |
Write-Host "New value for runJob $(runJob)"