Azure Devops Pipeline: Second parameter dependent on the first parameter
I am afraid there is no such out of way to resolve this question at this moment.
That because the conditions does not support for parameters at present. We could not add condition to the second parameter to set the value based on the first parameter.
As we know, the Runtime parameters is used to let you have more control over what values can be passed to a pipeline.
Since the second parameter is depend on the first parameter, does not require us to manually control it.
So, as workaround for this question, we could use the Logging Command with condition to set the second parameter based on the value of first parameter:
parameters:
- name: parametr1
displayName: example1
type: string
default: first
values:
- first
- second
- third
trigger: none
jobs:
- job: build
displayName: build
pool:
name: MyPrivateAgent
steps:
- task: InlinePowershell@1
displayName: 'SetVariableV1'
inputs:
Script: 'Write-Host "##vso[task.setvariable variable=parametr2.1;]123456"'
condition: and(succeeded(), eq('${{ parameters.parametr1 }}', 'first'))
- task: InlinePowershell@1
displayName: 'SetVariableV2'
inputs:
Script: 'Write-Host "##vso[task.setvariable variable=parametr2.2;]true"'
condition: and(succeeded(), eq('${{ parameters.parametr1 }}', 'second'))
I test it on my side, it works fine.