I have for my BU around 150 Build and Release pipelines for a single project. Now I need to create similar pipelines for different instance (couple of parameters that change to differentiate) and I have these new codes submitted on a new branch. They are very much the same tasks but the codes can be targeting different features on each of these branches. Hence to differentiate the codes (Same solution cloned for the same module but different developers working on different features) we have the new branch cloned with the change to the name and couple of parameters in the codes. So recreating those 150 pipelines becomes very onerous. Again we have similarly around 5 different instances of such groups leading to around 750 or more pipelines. Is there a short way to clone the entire 150 pipelines ? second it would be good to be able to change the parameters atfront instead of editing each of it and changing the parameters. Again there is a great consistency in what needs to be changed to differentiate it from the previous instance of the pipelines. I was looking at CLI or YAML and have been totally run out of ideas...
1 Answers
Clone Build and Release Pipelines for Azure devops
There is no such out of box way to clone build and releae pipelines at this moment.
As workaround, we could use the REST API Definitions - Create:
POST https://dev.azure.com/{organization}/{project}/_apis/build/definitions?api-version=5.0
But we need provide too much information in the Request Body, this will be a big project and error-prone. That also the reason why the document not provide a sample Request Body there.
To resolve this issue, usually we would use the REST API Definitions - Get to get the Response Body from the template pipeline:
GET https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=5.0
Then we just need to update the corresponding properties by modifying the Response Body.
Now, we get the new Request Body for the new pipeline, we could use it with REST API Definitions - Create
to create a new pipeline.
For example:
$uri = 'https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.0'
$result = Invoke-RestMethod -Method Get -Uri $uri -UseDefaultCredentials
$result.path = '\NewFolder\Location'
$result.name = "$result.name+clone"
$body = $result | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method POST -uri 'https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.0' -UseDefaultCredentials -Body $body -ContentType 'application/json'
You could check this thread and this thread for some more details.
If your pipeline is YAML mode, you could also use another way to clone the pipelines:

- 71,098
- 10
- 114
- 135