Im trying to pass variables between stages with jobs that is using templates in azure pipeline , tried a lot of methods but still did not managed to achieve it.
i have job that is checking something and create vso task.variable and this variables i want to pass to next stage
azure-pipelines.yaml
stages:
- stage: CheckProjectType
displayName: Check Project Type
jobs:
- template: jobs/checkprojectype.yaml@devops
- stage: PrintProjectType
dependsOn: CheckProjectType
displayName: Print Project Type
jobs:
- template: jobs/buildproject.yaml@devops
parameters:
outputval: $[ stagedependencies.CheckProjectType.outputs['SetValueStep.projecttype'] ]
checkprojectype.yaml
jobs:
- job: CheckProjectType
displayName: Check Project Type
steps:
- bash: |
if [ -f *.xml ]; then
echo "JAVA"
elif [ -f *.json ]; then
echo "json file found , Nodejs Project Will Be Built"
echo "##vso[task.setvariable variable=projecttype;]nodejs"
elif [ -f *.py ]; then
echo "Python"
else
echo "Not Found"
fi
name: itay
displayName: Checking Current Location
buildproject.yaml
jobs:
- job: BuildProject
variables:
- name: myvar123
value: ${{ parameters.outputval }}
steps:
- bash: echo $(myvar123)
and i expect to get nodejs , but I Dont get anything , the echo is empty