Pipeline Templates: Runtime Parameters in Azure DevOps Pipelines

It appears that the Runtime Parameters of Azure DevOps Pipelines has rolled out to most organisations. As such I thought it important that the Pipeline Templates are updated to use strongly typed boolean parameters. For example in the following YAML taken from the Windows Build template has a parameter, build_windows_enabled, which is typed as a boolean.

parameters:
# stage_name - (Optional) The name of the stage, so that it can be referenced elsewhere (eg for dependsOn property). 
# Defaults to 'Build_Windows'
- name: stage_name
  type: string
  default: 'Build_Windows'
# build_windows_enabled - (Optional) Whether this stages should be executed. Note that setting this to false won't completely
# cancel the stage, it will merely skip most of the stages. The stage will appear to complete successfully, so
# any stages that depend on this stage will attempt to execute
- name: build_windows_enabled
  type: boolean
  default: true

Previously, the parameters were passed in using variables defined in the main pipeline. The issue with this is that all variables are strings, so there’s no checking that a valid value has been passed in. For example:

Now we have the option of defining runtime parameters. These are parameters that are defined in the main pipeline yml file (ie not in a template). In the following example there are three runtime parameters defined; all boolean; all with a default value of true.

When we manually run this pipeline we’re now presented with a user interface that allows the user to adjust these runtime parameters, before hitting Run.

Another useful feature in the Run dialog is the Resources section

The Resources section lists referenced templates.

Clicking through on a template allows the user to adjust what version of the template to use. This is particularly useful if you are testing a new version of a template because you can Run a build referencing a different version, without making (and committing) a change to the actual pipeline.

Pipeline Templates v0.6.0

Here’s a summary of what’s in release v0.6.0:

Breaking Changes:

  • build-xamarin-[iOS/android/windows].yml and deploy-appcenter.yml – XXX_enabled parameter (eg windows_enabled or deploy_enabled) are now strongly typed as boolean parameters. This means you need to supply either a literal value (eg true or false) or a parameter. Use runtime parameters instead of pipeline variables to ensure values are strongly typed as boolean.

Other Changes:

  • none

2 thoughts on “Pipeline Templates: Runtime Parameters in Azure DevOps Pipelines”

  1. Hi, I want to pass o/p one step to another step.for example,i need to call small first and output of small should be captured and passed as input variable to medium.How is that possible?
    template: windows-tests.yml
    parameters: integration_tests: [“Small”, “Medium”]
    check_status: “$(Powershell1.var)”

    code inside small test
    $error_Code=$?
    if (“$error_Code” -eq “True” -and “$(Powershell2.check_status)” -eq “true”)
    {
    Write-Host “##vso[task.setvariable variable=check_status;isOutput=true]true”
    }
    else { Write-Host “##vso[task.setvariable variable=check_status;isOutput=true]false”
    }

    Reply
    • When you create output variable, you need to be aware that they will be prefixed by the name of the task. If your task is named “Small”, then the output variable would be “Small.check_status”. Also, if you want to make this available between different Jobs, you need to setup a dependency between the jobs and then you would access them as Dependencies.JobName.Small.check_status

      Reply

Leave a comment