This is an issue we have reported to the product team : https://developercommunity.visualstudio.com/content/problem/1000544/parameters-to-api-rest-build-queue-method.html
Currently as a workaround we can use below undocumented REST API (tracked by develop tool) to trigger the YAML pipeline by passing the parameters.
POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineID}/runs?api-version=5.1-preview.1
Content-Type: application/json
Accept: application/json
Request body:
{
"stagesToSkip":[],
"resources":{
"repositories":{
"self":{
"refName":"refs/heads/master"
}
}
},
"templateParameters":{
"image":"ubuntu-16.04",
"var1":"variable1"
},
"variables":{}
}
Yaml file for your reference:
parameters:
- name: image
displayName: Pool Image
type: string
default: ubuntu-latest
values:
- windows-latest
- vs2017-win2016
- ubuntu-latest
- ubuntu-16.04
- macOS-latest
- macOS-10.14
- name: var1
displayName: var1
type: string
default: variable2
values:
- variable1
- variable2
- variable3
- variable4
trigger: none
jobs:
- job: build
displayName: build
pool:
vmImage: ${{ parameters.image }}
steps:
- script: echo building $(Build.BuildNumber) with ${{ parameters.image }}
- script: echo building $(Build.BuildNumber) with ${{ parameters.var1 }}