Oct 24 2023
11:28 AM
- last edited on
Mar 05 2024
04:57 PM
by
TechCommunityAP
Oct 24 2023
11:28 AM
- last edited on
Mar 05 2024
04:57 PM
by
TechCommunityAP
Hi,
The azure devops server API allows creation of a Pipeline: https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops...
If you follow this link, you likely want to start from an existing pipeline object, so I did that. Easy enough, query a pipeline by ID, and then look to call the one above. You'll hit an error saying you need to specify a repoName, that it's null. Ok, not sure why, it's got an ID, but that works. This probably should just be added to the documentation. Not a huge deal.
$pipelineObj.configuration.repository | Add-Member -NotePropertyName name -NotePropertyValue $reposName
The real issue is my need is that i want to back up my pipeline from one server to the other. I can easily update the repository ID to match the target server, no problem, that all works for a regular pipeline. But I have some pipelines that don't have their YAML files on the default branch (typically named master). For those, every time i try to create it on the destination, I get the following error (redacted):
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"File /<FILENAME> not found in
repository <SERVER NAME>/_git/<REPO NAME> branch
refs/heads/master version <COMMIT ID>.","typeName":"Microsoft.TeamFoundation.DistributedTa
sk.Pipelines.YamlFileNotFoundException, Microsoft.TeamFoundation.DistributedTask.Pipelines.Yaml","typeKey":"YamlFileNot
FoundException","errorCode":0,"eventId":3000}
There is no conceivable way to inform the creation statement that I know this to be the case, and i want to check a specific branch. There's a pipeline default branch functionality -> you can set that, but it has no effect. It's still checking the repository default branch and failing if the file doesn't exist:
$pipelineObj.configuration.repository | Add-Member -NotePropertyName defaultBranch -NotePropertyValue $defaultBranch
Any idea why this restriction is there and how to bypass it?
thanks,
Matt