Skip to content

Instantly share code, notes, and snippets.

@thomast1906
Last active October 13, 2021 18:06
Show Gist options
  • Save thomast1906/15c5040ba48328c443f3c8df3dd0ff32 to your computer and use it in GitHub Desktop.
Save thomast1906/15c5040ba48328c443f3c8df3dd0ff32 to your computer and use it in GitHub Desktop.
Conditional variable of a variable in Azure DevOps Pipeline
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