What is the right syntax for removing a particular value in a parameter in a Azure YAML pipeline?
Scenario:
Parameters:
- name: App_Name
type: string
values: ABC_CARD_GAME
ABC_CARD_GAME2
ABC_CARD_GAME3
Echo ${{parameters.App_Name}}
For example: If I choose ABC_CARD_GAME
from the list, the desired result would be CARD_GAME
(without the ABC
).
I tried using the replace expression but that is not what I wanted to achieve.
We can use the replace or split expressions.
Sample Yaml:
trigger:
- none
pool:
vmImage: ubuntu-latest
parameters:
- name: App_Name
type: string
values:
- ABC_CARD_GAME1
- ABC_CARD_GAME2
- ABC_CARD_GAME3
steps:
- script: echo Hello, world! This is ${{ replace(parameters.App_Name, 'ABC_', '') }}
displayName: 'replace'
- script: echo Hello, world! This is ${{ split(parameters.App_Name, '_')[1] }}_${{ split(parameters.App_Name, '_')[2] }}
displayName: 'split'