Hi,
I'm trying to reuse parameters in a template. When using them as conditions, it works fine.
When trying to reuse them as tasks' parameters, it doesn't work so well.
Example: I would like to reuse parameters.os as an input parameter for the PublishTestResults task and display either Linux Tests or Windows Tests in the build summary, using the testRunTitle input of the task.
I've tried with ${{ parameters.os }}, $(parameters.os) without success.

Is this possible? Am I missing something?
Thanks!
My .vsts-ci.yml file
phases:
# Linux
- phase: build_all_linux
displayName: Build all tasks (Linux)
queue:
name: Azure
demands:
- agent.OS -equals linux
steps:
- template: ci/build-all-steps.yml
parameters:
os: Linux
# Windows
- phase: build_all_windows
displayName: Build all tasks (Windows)
queue:
name: Azure
demands:
- agent.OS -equals Windows_NT
steps:
- template: ci/build-all-steps.yml
parameters:
os: Windows
My ci/build-all-steps.yml
parameters:
os: ''
steps:
# some
# tasks
# here
# publish tests results
- task: PublishTestResults@2
displayName: Publish Test Results
inputs:
testResultsFiles: '**/test-results.xml'
mergeTestResults: true
# this is where I'm stuck, expecting 'Linux Tests' or 'Windows Tests'
testRunTitle: ${{ parameters.os }} Tests
@BiribiriJaNai
try following:
phases:
# Linux
- phase: build_all_linux
displayName: Build all tasks (Linux)
queue:
name: Azure
demands:
- agent.OS -equals linux
steps:
- template: ci/build-all-steps.yml
parameters:
testTitle: Linux Tests
# Windows
- phase: build_all_windows
displayName: Build all tasks (Windows)
queue:
name: Azure
demands:
- agent.OS -equals Windows_NT
steps:
- template: ci/build-all-steps.yml
parameters:
testTitle: Windows Tests
parameters:
testTitle: ''
steps:
# some
# tasks
# here
# publish tests results
- task: PublishTestResults@2
displayName: Publish Test Results
inputs:
testResultsFiles: '**/test-results.xml'
mergeTestResults: true
# this is where I'm stuck, expecting 'Linux Tests' or 'Windows Tests'
testRunTitle: ${{ parameters.testTitle}}
testRunTitle: ${{ format('{0} Tests', parameters.testTitle }}
I added this example to the docs https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-templateexpressions.md#functions
Thanks @TingluoHuang and @ericsciple.
Worked like a charm!
@BiribiriJaNai thanks for the confirmation.
Also note, we would like to enable the more intuitive form:
testRunTitle: ${{ parameters.testTitle }} Tests
...we just havent gotten to it yet.
@ericsciple The example you've provided on 9th of July causes a 'format not closed' error. When adding a closing parenthesis it will work:
testRunTitle: ${{ format('{0} Tests', parameters.testTitle }})
@HermanCordes , I think your closing parenthesis is misplaced. It should be right after testTitle.
And I just realized that the the sample provided by @ericsciple is missing its closing parenthesis.
What worked for me : testRunTitle: ${{ format('{0} Tests', parameters.testTitle) }}
@BiribiriJaNai You're right, apparently I made a copy+paste error. Thanks for the correction.
@BiribiriJaNai when the next sprint rolls out, you will be able to do this:
parameters:
os: ''
steps:
- task: PublishTestResults@2
displayName: Publish Test Results
inputs:
testRunTitle: ${{ parameters.os }} Tests
It will start rolling out after next week, and will take about three weeks to finish rolling out to all accounts.
Hi Eric,
is this feature now rolled out to all accounts?
In my case I have the same issue and found this thread.


I use now the format-workaround; but would be nice if inlining would be available too (and documentated) :-)
It hasn't rolled out to all accounts yet. Based on where it's currently at, I would expect the deployment to finish rolling everywhere either late this week or early next week.
@ericsciple If we reference multiple templates in a vsts-ci.yml files (i.e: multiple pipeline yml files) is there a way to have them not run in parallel? can I use a dependsOn?
phases:
Today you would need to map in the dependsOn via a template parameter.
We are planning support soon for stages, so you can easily group jobs and define dependencies between stages. Hopefully that will land sometime in the next few sprints (we work in 3 week sprints).
@ericsciple
I need to pass the variables into templates.for example.ouput of small should be passed as input to medium.how is this possible?
template: windows-tests.yml
parameters:
integration_tests: ["Small", "Medium"]
check_status: "$(Powershell2.var)"
inside the template:
$error_Code=$?
if ("$error_Code" -eq "True" -and "$(Powershell2.check_status)" -eq "false")
{
Write-Host "##vso[task.setvariable variable=check_status;isOutput=true]true"
}
else
{
Write-Host "##vso[task.setvariable variable=check_status;isOutput=true]false"
}
o/p from build step with be stored in checkstatus variable and will be passed to template.
Powershell1.var will be used by small test and then generated a value which needs to be used by medium.
Most helpful comment
@BiribiriJaNai when the next sprint rolls out, you will be able to do this:
It will start rolling out after next week, and will take about three weeks to finish rolling out to all accounts.