Created
March 28, 2022 21:23
-
-
Save philip-gai/89647ecada163d9217a982324f9ab4ac to your computer and use it in GitHub Desktop.
Azure DevOps Pipeline Dependencies Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pipeline | |
stages: | |
- stage: set_output_variables_stage | |
displayName: Set output variables | |
pool: ubuntu-latest | |
jobs: | |
- job: set_output_variables_job | |
displayName: Set output variables | |
steps: | |
- pwsh: | | |
$name = "philip-gai" | |
Write-Host "Setting NAME output variable to $name" | |
# Use this if you need to access $env:NAME in a future job in the same stage | |
# Write-Host "##vso[task.setvariable variable=NAME;]$name" | |
Write-Host "##vso[task.setvariable variable=NAME;isOutput=true]$name" | |
displayName: Set output variables | |
name: set_output_variables_task | |
- stage: use_output_variables | |
displayName: Use output variables | |
pool: ubuntu-latest | |
dependsOn: | |
- set_output_variables_stage | |
# Map variables in on the stage level from the previous stage | |
variables: | |
- name: STAGE_LEVEL_NAME | |
value: $[ stageDependencies.set_output_variables_stage.set_output_variables_job.outputs['set_output_variables_task.NAME'] ] | |
jobs: | |
- job: use_output_variables_job | |
displayName: Use output variables | |
# Map variables in on the job level from the previous stage | |
variables: | |
- name: JOB_LEVEL_NAME | |
value: $[ stageDependencies.set_output_variables_stage.set_output_variables_job.outputs['set_output_variables_task.NAME'] ] | |
steps: | |
# Check if a previous stage was canceled | |
- pwsh: | | |
Write-Host "Stage level name: $($env:STAGE_LEVEL_NAME)" | |
Write-Host "Job level name: $($env:JOB_LEVEL_NAME)" | |
displayName: Test variables | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment