You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps迁移时无法通过REST API创建经典管道求助

解决Azure DevOps REST API创建经典管道报错问题

问题根源

你当前调用的Azure DevOps Pipelines API(pipelines/create)仅支持YAML管道创建,不兼容经典设计师模式的管道(DesignerJson类型),因此抛出UnsupportedConfigurationTypeException错误。经典管道本质属于Build Definition范畴,需使用Build Definitions的REST API完成创建。

解决方案

1. 替换为正确的API端点

使用Build Definitions创建接口替代原API:

POST https://dev.azure.com/{organization}/{project}/_apis/build/definitions?api-version=7.1-preview.7

(api-version可根据Azure DevOps版本调整,推荐使用最新预览版或稳定版)

2. 调整请求体结构

移除原请求体中外层的configuration和type: "designerJson"节点,将designerJson内的内容直接作为请求体的根节点。调整后的请求体示例如下:

{
    "name": "PP_NAME",
    "folder": "",
    "options": [
        {
            "enabled": false,
            "definition": {
                "id": "DEF_ID"
            },
            "inputs": {
                "branchFilters": "[\"+refs/heads/*\"]",
                "additionalFields": "{}"
            }
        },
        {
            "enabled": false,
            "definition": {
                "id": "DEF_ID"
            },
            "inputs": {
                "workItemType": "Task",
                "assignToRequestor": "true",
                "additionalFields": "{}"
            }
        }
    ],
    "variables": {
        "system.debug": {
            "value": "false",
            "allowOverride": true
        }
    },
    "tags": [],
    "process": {
        "phases": [
            {
                "name": "Agent job 1",
                "refName": "Job_1",
                "condition": "succeeded()",
                "target": {
                    "executionOptions": {
                        "type": 0
                    },
                    "allowScriptsAuthAccessOption": false,
                    "type": 1
                },
                "jobAuthorizationScope": "project"
            }
        ],
        "target": {
            "agentSpecification": {
                "identifier": "windows-2019"
            }
        },
        "type": 1
    },
    "quality": "definition",
    "path": "\\",
    "repository": {
        "id": "REPOSITORY_ID",
        "name": "test 1",
        "type": "TfsGit"
    }
}

3. 关键验证项

  • 确认repository.id是目标项目中对应Git仓库的正确ID
  • options中的DEF_ID需替换为实际的任务ID(例如CI触发器ID为8C4F8F2D-3B17-497C-8198-3FD9102DDC9A,工作项关联ID为E4126E65-637A-4C7D-9ECF-690BDD663D4E,可通过任务定义查询API获取)
  • process.target.agentSpecification.identifier需与目标项目中可用的代理规格匹配

内容的提问来源于stack exchange,提问作者Shachar297

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 17:30:47