I have successfully been able to run the below. I would like to alter this to work with passed in params. I don't mind how I get the params in. I just want to be able to programatically pass them in.My question is what is the syntax to pass via the rest api or the gui. See my attempt script at the bottom.
pipeline
jobs: - template: patch-template.yml parameters: liststuff: - HostName: A Prop: XXXX - HostName: B Prop: YYYY
being used in a template as
parameters: - name: liststuff type: object default: [] jobs: - '${{ each item in parameters.liststuff }}': - template: patch-tasks.yml parameters: prop: '${{ item.Prop }}' hostname: '${{ item.hostname }}'
and steps implemented
jobs: - job: displayName: 'Job_${{ parameters.prop }}' steps: - task: PowerShell@2 inputs: targetType: 'inline' script: | Write-Host "prop '${{ parameters.prop }}'" Write-Host "host '${{ parameters.hostname }}'"
Issue bit: changed pipeline to work with passed in params. I don't mind how I get the params in. I just want to be able to programatically pass them in.
parameters: - name: InstanceArgs type: object default: [] jobs: - template: patch-template.yml parameters: liststuff: '${{ parameters.InstanceArgs }}'
and utilising api with powershell
$url="https://dev.azure.com/{comp}/{project}/_apis/pipelines/{id}/runs?api-version=5.1-preview" $token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)")) $JSON = @' { "templateParameters": { "listsuff": [{ "hostname": "D", "prop": "ZZZZ" }] } } '@ Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -Body $JSON -ContentType application/json