Azure Devops rest API 用于使用源提供程序 bitbucket 不工作来创建管道

Azure Devops rest API for create pipeline with source provider bitbucket not working

我是 Azure 的新手,正在尝试通过 rest api 创建管道 URL https://dev.azure.com/my-org/my_project/_apis/pipelines?api-version=6.1-preview.1

Source Provider 是 Azure Git Repo 时,它可以很好地处理下面的请求正文

{
  "folder": "\",
  "name": "Test-Pipeline-1",
  "configuration": {
        "type": "yaml",
        "path":"/azure-pipelines.yml",
        "repository":{
            "id": "1f13f61c-eade-b36bc515bb5e",
             "name": "TestAzure123",
             "type":"azureReposGit"
        }
  }
}

但是当 Source Provider 是 Bitbucket Cloud 时,它不起作用

{
  "folder": "\",
  "name": "Bitbucket-Pipeline",
  "configuration": {
        "type": "yaml",
        "path":"/master-pipeline.yaml",
        "repository": {
                "id": "sid_07/Bitbucket-repository",
                "name": "Bitbucket-repository",
                "type": "Bitbucket"
            }
  }
}

我低于异常

{
    "$id": "1",
    "innerException": null,
    "message": "This API does not support creating pipelines with repositories of type Unknown.",
    "typeName": "Microsoft.Azure.Pipelines.WebApi.UnsupportedRepositoryTypeException, Microsoft.Azure.Pipelines.WebApi",
    "typeKey": "UnsupportedRepositoryTypeException",
    "errorCode": 0,
    "eventId": 3000
}

是否支持通过 rest api 为 bitbucket 创建管道?还是我错过了什么?请帮助

我已经参考了类似的问题 https://developercommunity.visualstudio.com/content/problem/1101376/create-pipeline-rest-api-does-not-work.html

Azure Devops rest API for create pipeline with source provider bitbucket not working

恐怕 REST API Pipelines - Create 目前不支持创建源类型为 bitbucket 的管道。

当我使用下面的请求体时,我用来为github的资源类型创建管道:

{
    "folder": "\",
    "name": "Test-Pipeline-2",
    "configuration": {
        "path": "TestDemo.yml",
        "repository": {
            "fullName": "xxx/leotest",
            "connection": {
                "id": "e11d299a-0bfd-4a38-a77c-xxxxxxxx"
            },
            "type": "bitbucket"
        },
        "type": "yaml"
    }

我遇到了和你一样的错误:

然后我手动创建了那个管道,并使用 REST API Pipelines - Get 来获取关于这个管道的详细信息,我得到了以下信息:

"configuration": {
    "path": "BitbucketRepo.yml",
    "repository": null,
    "type": "yaml"
},
"url": "https://dev.azure.com/xxx/xxxxx/_apis/pipelines/146?revision=2",
"id": 146,
"revision": 2,
"name": "BitbucketRepo",
"folder": "\YAML\Resources"

我们可以知道repository:的部分是null

因此,REST API Pipelines - Create 目前不支持使用源提供程序 bitbucket 创建管道。

对于此请求,您可以在我们的 UserVoice 网站 (https://developercommunity.visualstudio.com/content/idea/post.html?space=21 ) 上为该功能添加它,该网站是我们提供产品建议的主要论坛。感谢您帮助我们构建更好的 Azure DevOps。