Last active
October 13, 2021 18:06
-
-
Save thomast1906/15c5040ba48328c443f3c8df3dd0ff32 to your computer and use it in GitHub Desktop.
Conditional variable of a variable in Azure DevOps Pipeline
This file contains 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
variables: | |
- name: project | |
value: tamops | |
- name: teamName | |
${{ if eq( variables['project'], 'tamops') }}: | |
value: "alpha" | |
${{ if eq( variables['project'], 'preproduction' ) }}: | |
value: "beta" | |
${{ if notIn( variables['project'], 'tamops', 'preproduction') }}: | |
value: "charlie" | |
stages: | |
- stage: TeamToDeploy | |
jobs: | |
- job: Example | |
steps: | |
- task: Bash@3 | |
displayName: TeamDeployed | |
inputs: | |
targetType: inline | |
script: | | |
echo ${{variables.teamName}} | |
#### sample output | |
Starting: TeamDeployed | |
============================================================================== | |
Task : Bash | |
Description : Run a Bash script on macOS, Linux, or Windows | |
Version : 3.189.0 | |
Author : Microsoft Corporation | |
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash | |
============================================================================== | |
Generating script. | |
Script contents: | |
echo alpha |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment