Skip to content

Commit 25ea4ae

Browse files
Merge pull request #8575 from MicrosoftDocs/users/jukullam/coalesce
Update template expressions coalesce example
2 parents 1065939 + 6479721 commit 25ea4ae

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

docs/pipelines/process/template-expressions.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,22 @@ You can use [general functions](expressions.md#functions) in your templates. You
7878

7979
```yaml
8080
parameters:
81-
- name: 'restoreProjects'
82-
default: ''
81+
- name: 'customVersion'
8382
type: string
84-
- name: 'buildProjects'
8583
default: ''
84+
- name: 'defaultVersion'
8685
type: string
86+
default: '1.0.0'
8787
8888
steps:
89-
- script: echo ${{ coalesce(parameters.foo, parameters.bar, 'Nothing to see') }}
89+
- script: echo Version is ${{ coalesce(parameters.customVersion, parameters.defaultVersion) }}
9090
```
9191

92+
> [!NOTE]
93+
> String parameters with `default: ''` (empty string) behave differently depending on how you trigger the pipeline:
94+
> * **In the pipeline editor**: You can run the pipeline directly and the empty string default is respected, allowing `coalesce` to fall back to the next value.
95+
> * **In the Run Pipeline pane**: Azure DevOps requires you to provide a non-empty value for parameters with empty string defaults, preventing `coalesce` from falling back.
96+
9297
### Insertion
9398

9499
You can use template expressions to alter the structure of a YAML pipeline.

0 commit comments

Comments
 (0)