Skip to content

Instantly share code, notes, and snippets.

@scholz
Last active March 14, 2022 14:55
Show Gist options
  • Save scholz/b8b80b2c4ff8ae90a71910ef2a8f03a6 to your computer and use it in GitHub Desktop.
Save scholz/b8b80b2c4ff8ae90a71910ef2a8f03a6 to your computer and use it in GitHub Desktop.
example to access variables accross stages using stageDependencies with bash in azure devops
trigger:
- main
pool:
vmImage: ubuntu-latest
stages:
- stage: create_var_stage
jobs:
- job: create_var_job
steps:
- script: |
TEST_TAG="my_test_tag_0.1.0"
echo "##vso[task.setvariable variable=TEST_TAG;isOutput=true]$TEST_TAG"
name: create_var_task
- stage: test_var_stage
# this is mandatory if the stage you want to get var from is not directly executed before this stage
dependsOn: create_var_stage
jobs:
- job: test_var_job
# define vars which are available in the complete job
variables:
TEST_TAG: $[ stageDependencies.create_var_stage.create_var_job.outputs['create_var_task.TEST_TAG']]
steps:
- script: |
echo "------"
echo $(TEST_TAG)
echo "----"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment