Hi I have a yml pipeline in azure devops.
variables:
- name: dependencyChanged
value: false
-stage: stage1
jobs:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
CHANGED_FILES=$(git diff HEAD HEAD~ --name-only)
DEPENDENCY_CHANGED=$(echo "$CHANGED_FILES" | grep -q "aml/ml_service/docker/" && echo "true" || echo "false")
echo "##vso[task.setvariable variable=dependencyChanged=true;isOutput=true]]$DEPENDENCY_CHANGED"
echo "Debug: adfChanged value is '${{ variables['dependencyChanged'] }}'"
-stage: stage2
condition: and(succeeded('stage1'), eq(variables['dependencyChanged'], 'true'))
jobs:
.... some jobs here
The problem is:
DEPENDENCY_CHANGED is ‘true’
and dependency_change is also true becasue it is set from DEPENDENCY_CHANGED
but stage2 never gets executed, not sure why.
even if if do
echo “##vso[task.setvariable variable=dependencyChanged=true;isOutput=true]]’true'”
In summary, I want to update the pipeline variables with in different stages and access them in multiple stages.
I think the task.setvariable
line should read
echo "##vso[task.setvariable variable=dependencyChanged;isOutput=true]$DEPENDENCY_CHANGED"
also if you want to reference it in another stage you should use
condition: and(succeeded('stage1'), eq(dependencies.stage1.outputs['PUTYOURTASKNAMEHERE.dependencyChanged'], 'true'))
And replace PUTYOURTASKNAMEHERE appropriately