首页 > 解决方案 > YAML 模板可选步骤参数空值应该是什么?

问题描述

当使用这样的模板参数时:

parameters:
- name: runStep
  type: step

它总是需要传递一个值。但是,我想将其设为可选:

parameters:
- name: runStep
  type: step
  default: ???

因为stepList它可以这样做:

- name: runSteps
  type: stepList
  default: []

但是 type 怎么做step呢?我可以添加一个“虚拟”默认值:

default:
  script: echo 123

但是,我如何在条件下比较该值?我想做这样的事情:

- ${{ if parameters.runStep }}:
  - ${{ parameters.runStep }}

标签: azureazure-pipelinesazure-pipelines-yaml

解决方案


Would this work for you?

step:
- bash: |
    if [ ${{parameters.runstep}} ]; then
       ${{parameters.runstep}}
    fi

推荐阅读