Greetings to my fellow Technology Advocates and Specialists.
In this Session, I will demonstrate Dropdown OR Radio button options in Azure Devops.
AUTOMATION OBJECTIVES:- |
---|
# | TOPICS |
---|---|
1. | Radio Button option as Runtime Variables in Azure Devops Pipelines. |
2. | Dropdown Menu option as Runtime Variables in Azure Devops Pipelines. |
3. | Spot the difference. |
IMPORTANT NOTE:- |
---|
The YAML Pipeline is tested on WINDOWS BUILD AGENT Only!!!
REQUIREMENTS:- |
---|
- Azure Subscription.
- Azure DevOps Organisation and Project.
- Service Principal with Required RBAC ( Contributor) applied on Subscription or Resource Group(s).
- Azure Resource Manager Service Connection in Azure DevOps.
HOW DOES MY CODE PLACEHOLDER LOOKS LIKE:- |
---|
1. RADIO BUTTON OPTION AS RUNTIME VARIABLES:- |
---|
PIPELINE CODE SNIPPET:- |
---|
AZURE DEVOPS YAML PIPELINE (azure-pipelines-runtime-parameter-options-v1.0.yml):- |
---|
trigger:
none
##################
# Radio Button:-
##################
parameters:
- name: environment
displayName: Select environment
type: string
default: 'dev'
values:
- dev
- test
- uat
#############
#Variables:-
############
variables:
ServiceConnection: 'amcloud-cicd-service-connection' # Please replace with your Service Connection!
BuildAgent: 'windows-latest' # Please replace with your Build Agent. You can continue to use this as this is Microsoft Hosted Windows Build Agent!
######################
# Declare Build Agent:-
######################
pool:
vmImage: '$(BuildAgent)'
##################################
# Declare Stages:-
# Test Runtime parameters as:-
# 1. Radio Button
##################################
stages:
- stage: Test_Runtime_Parameters_RadioButton
displayName: Test Runtime Parameters Radio Button
jobs:
- job: Test_Runtime_Parameters_RadioButton
steps:
- task: AzureCLI@2
displayName: Test Runtime Parameters RadioButton
inputs:
azureSubscription: '$(ServiceConnection)'
scriptLocation: 'inlineScript'
scriptType: 'ps'
inlineScript: |
echo "Deploying to ${{ parameters.environment }} environment"
CODE BLOCK FOR RADIO BUTTON AS RUNTIME VARIABLES IN YAML:- |
---|
##################
# Radio Button:-
##################
parameters:
- name: environment
displayName: Select environment
type: string
default: 'dev'
values:
- dev
- test
- uat
OUTPUT: RADIO BUTTON OPTION AS RUNTIME VARIABLES |
---|
1. Radio Button as runtime variables is displayed successfully on Pipeline Execution. |
2. Successful Pipeline Execution. |
2. DROPDOWN MENU OPTION AS RUNTIME VARIABLES:- |
---|
PIPELINE CODE SNIPPET:- |
---|
AZURE DEVOPS YAML PIPELINE (azure-pipelines-runtime-parameter-options-v1.1.yml):- |
---|
trigger:
none
##################
# Drop Down Menu:-
##################
parameters:
- name: environment
displayName: Select environment
type: string
default: 'dev'
values:
- dev
- test
- uat
- prod
#############
#Variables:-
############
variables:
ServiceConnection: 'amcloud-cicd-service-connection' # Please replace with your Service Connection!
BuildAgent: 'windows-latest' # Please replace with your Build Agent. You can continue to use this as this is Microsoft Hosted Windows Build Agent!
######################
# Declare Build Agent:-
######################
pool:
vmImage: '$(BuildAgent)'
##################################
# Declare Stages:-
# Test Runtime parameters as:-
# 1. Dropdown Menu
##################################
stages:
- stage: Test_Runtime_Parameters_DropDown_Menu
displayName: Test Runtime Parameters Dropdown Menu
jobs:
- job: Test_Runtime_Parameters_DropDown_Menu
steps:
- task: AzureCLI@2
displayName: Test Runtime Parameters Dropdown Menu
inputs:
azureSubscription: '$(ServiceConnection)'
scriptLocation: 'inlineScript'
scriptType: 'ps'
inlineScript: |
echo "Deploying to ${{ parameters.environment }} environment"
CODE BLOCK FOR DROPDOWN MENU AS RUNTIME VARIABLES IN YAML:- |
---|
##################
# Drop Down Menu:-
##################
parameters:
- name: environment
displayName: Select environment
type: string
default: 'dev'
values:
- dev
- test
- uat
- prod
OUTPUT: DROPDOWN MENU OPTION AS RUNTIME VARIABLES |
---|
1. Dropdown Menu as runtime variables is displayed successfully on Pipeline Execution. |
2. Successful Pipeline Execution. |
3. SPOT THE DIFFERENCE:- |
---|
The "type" of the variable is exactly the same except the no. of values. For "Radio button", we entered 3 values but if we needed "Dropdown Menu", we just increased 1 more value. "Radio button" option changes to "Dropdown Menu". |
For "Radio button", value count <= 3 |
For "Dropdown Menu", value count > 3 |
Hope You Enjoyed the Session!!!
Stay Safe | Keep Learning | Spread Knowledge