You could use the method described here: https://stackoverflow.com/a/73200692/511105
ie.
a) You define a parameter per stage with a default false value.
parameters:
- name: deployDEV
displayName: Deploy to DEV
type: boolean
default: false
b) You bind it as an equality comparator in its associated stage condition.
condition: eq(${{ parameters.deployDEV }}, true)
c) Then, using the REST API, in the BODY construction, set the desired
parameter to true:
> "
> {
> "stagesToSkip": [],
> "resources": {
> "repositories" : {
> "self": {
> "refName": "$refName"
> }
> }
> },
> "templateParameters": {
> "deployDEV": "true"
> },
> "variables": { }
> } "
The other option would be to have a function building the string array of all the pipeline associated stages minus the one you want to deploy on. Then, pass the results in the same way inside the BODY message inside the stagesToSkip": [] value.