I'm using below yaml file to build pipeline. It is defined with 2 variables.
parameters:
- name: tag
type: string
default: '@Test1'
- name: forkCount
type: number
default: 0
variables:
- name: ENV
value: QA
- name: fork_opt
value: ''
${{ if gt(parameters.forkCount, 0) }}:
fork_opt: '-DforkCount=${{ parameters.forkCount }} -Dhub=https://huburl.com' --> Getting error here
${{ else }}:
fork_opt: '
stages:
#stages to be follow. task uses fork_opt
I have a user-defined variable (ENV) which is static. I defined another variable (fork_opt) - whose value should be assigned at run time based on the 'forkCount' parameter value
When I run a pipeline, getting below error
/azure-pipelines-generic.yml (Line: 18, Col: 7): Unexpected value 'fork_opt'
How can I resolve this?
Fixed it through below syntax
variables:
- name: ENV
value: QA
- ${{ if gt(parameters.forkCount, 0) }}:
- name: fork_opt
value: '-DforkCount=${{ parameters.forkCount }} -Dhub=https://huburl.com'
- ${{ else }}:
- name: fork_opt
value: ''