Reputation: 8158
When using a template parameter like this:
parameters:
- name: runStep
type: step
It always requires passing a value. I would, however, like to make it optional:
parameters:
- name: runStep
type: step
default: ???
For stepList
it can be done like so:
- name: runSteps
type: stepList
default: []
But how could it be done for type step
? I could add a "dummy" default value:
default:
script: echo 123
However, how could I compare that value in a condition? I'd like to do something like this:
- ${{ if parameters.runStep }}:
- ${{ parameters.runStep }}
Upvotes: 1
Views: 1867
Reputation: 76910
What should a YAML template optional step parameter default value be?
According to the document Template types & usage:
So, the default value of YAML template optional step parameter should be a step, like:
parameters:
- name: myStep
type: step
default:
script: echo my step
steps:
- ${{ if parameters.runStep }}:
- ${{ parameters.runStep }}
- script: echo HelloWorld!
Upvotes: 0
Reputation: 1605
Would this work for you?
step:
- bash: |
if [ ${{parameters.runstep}} ]; then
${{parameters.runstep}}
fi
Upvotes: 1