How to allow an empty string for a runtime parameter?

Single whitespace of runtime parameter is not interpreted as empty. In the example demonstrated by author, the run time parameter is firstly passed to an environment variable MS. This step can trim leading and trailing whitespaces. That's why MS is an empty string. If try this:

parameters:
- name: myString
  type: string
  default: ' '

steps:
- script: |
    echo ">>${{ parameters.myString }}<<"

it will produce:

>> <<

Anyway, passing runtime parameter to script through environment variable is a good workaround trimming whitespace. Otherwise, we have to deal with the whitespace issue in script.


As per the documentation, "parameters cannot be optional".

Putting a space ' ' as the default value will work (as Krzysztof suggested), but the space will remain in the field. If you delete the space in the field so that there is no text value, the default value of ' ' will be used when the pipeline is run.


This is really strange. But if you put instead of '' a space ' ' you will be able to trigger pipeline, even deleting that space from field.

build with runtime parameters