I am tring to create Azure devops (tfs) Pipeline by rets API as described here: https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.0
Request url: https://tfs.xxx/tfs/Projects/xxx/_apis/pipelines?api-version=6.0-preview
Request body:
{
"folder": null,
"name": "pipeline-made-by-api",
"configuration": {
"type": "yaml",
"path": "build.yaml",
"repository": {
"id": "xxx",
"name": "xxx-repo",
"type": "azureReposGit"
}
}
}
I got error 400 with response:
{"$id":"1","innerException":null,"message":"Value cannot be null.rnParameter name: repositoryName","typeName":"System.ArgumentNullException, mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}
I don’t see any parameter called repositoryName in the documentation.
What am i missing?
Thanks!
2
Answers
Pipeline yaml be located in specific repository, so you must provide the repository id. A simple way to get your repository id:
azureDevopsRepositoryGet.ps1
Then you can pass the repository id into
azureDevopsPipelineCreate.ps1
How to get header
azureDevopsHearderGet.ps1
It appears the url
https://tfs.xxx/tfs/Projects/xxx/_apis/pipelines?api-version=6.0-preview
is not correct, at least there’s extraProjects
.For On-Prem ADO server(tfs), please fix the url with below format:
The
api-version
could be different based on different tfs version.On my ADO server 2022, below powershell script works. Please replace url and parameters, and try on your side.