How do I get the x element of a nested Azure DevOps pipeline parameter?
parameters:
- name: environment
type: object
default:
development:
description: Development env
vaults:
Vault-1: Vault-1-Connection
Vault-2: Vault-2-Connection
In my case I want to get the key and the value of the first element in the vaults
sub-object.
This doesn't work:
${{ each env in parameters.environment }}:
${{ env.vaults[0].key }}
${{ env.vaults[0].value }}
Please use the code as below to get the key and value of the first element in vaults sub-object. Please note: Vault-1 seems is unexpected symbol while parsing pipeline YAML, thus I replace it with Vault1.
steps:
- script: echo ${{parameters.environment.development.vaults.Vault1}} # echo nested object value
- ${{ each pair in parameters.environment.development.vaults }}: # echo nested object key and value
- ${{ if eq(pair.key,'Vault1')}}:
- script: echo "${{ pair.key }}, ${{ pair.value }}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.