# 提交前检测

如果使用 project_full_path,确保 project_full_path 编码过,例子:/api/v3/projects/tencent/code--> /api/v3/projects/tencent%2Fcode (/ 编码 %2F)

# 新建检测结果

检测结果创建

如需覆盖之前的检测结果,需流水线名称、token、context 字段一致。

POST /api/v3/projects/:id/commit/:sha/statuses

参数:

参数 类型 描述
id integer or string 项目 ID 或 项目全路径 project_full_path
sha string commit hash 值、分支名或 tag
state string 检测状态,可选值:
pending:正在检查中
success:流水线检查结果通过
error:是指的检测过程出错了,例如流水线执行出现异常
failure:流水线检查结果失败、不通过
target_url string 来源流水线、任务等检测路径,用于定位触发原因,最大字符长度:255
description string 检测结果描述,最大字符长度:255
context string(可选) 区别于其他检测系统的标签,默认:default
detail string(可选) 检测详情,支持 markdown 格式,最大字符串长度:65535
block boolean(可选) 是否锁住提交和合并请求,默认:false
target_branches List<string>(可选) 检查结果关联的 MR(按目标分支识别),target_branches 为空时(默认),检查展示在所有 MR 中,如果传入的目标分支等于~NONE,检查结果不展示在任一 MR 中

返回值:


{
    "id": 365,
    "state": "success",
    "target_url": "https://xxxxx.com/mr/check",
    "description": "CI check for mr",
    "context": "jenkins/mr",
    "detail": "commit check detail",
    "created_at": "2014-03-05T07:56:56+0000",
    "updated_at": "2014-03-05T07:56:56+0000",
    "block": true,
    "target_branches": []
}

# 通过 Ref 查询特定的组合检测结果

通过 Ref 查询组合的检测结果,需要有项目 developer 及以上权限。

GET /api/v3/projects/:id/commits/:ref/status

参数:

参数 类型 描述
id integer or string 项目 ID 或 项目全路径 project_full_path
ref string ref可以是SHA, branch name, tag name
target_branch string MR 目标分支
page integer 分页(默认:1
per_page integer 默认页面大小(默认: 20,最大: 100

返回值:

{
    "state": "pending",
    "block": false,
    "statuses": [
        {
            "id": 21,
            "state": "pending",
            "target_url": "https://xxxxx.com/push/check",
            "description": "check pending",
            "context": "jenkins/push",
            "detail": "commit check detail",
            "created_at": "2015-02-10T15:02:38+0000",
            "updated_at": "2015-02-10T15:02:38+0000",
            "block": true,
            "target_branches": []
        }
    ],
    "sha": "b5e3f65af2fd6d2895414a679290cad7664217b3",
    "total_count": 2
}

# 通过 Ref 查询检测结果

通过项目中的 Ref 查询检测结果

GET /api/v3/projects/:id/commits/:ref/statuses

参数:

参数 类型 描述
id integer or string 项目 ID 或 项目全路径 project_full_path
ref string ref可以是SHA, branch name, tag name
page integer 分页(默认:1
per_page integer 默认页面大小(默认: 20,最大: 100

返回值:

[
    {
        "id": 21,
        "state": "success",
        "target_url": "https://xxxx.com/mr/check",
        "description": "check success",
        "context": "jenkins/mr",
        "detail": "commit check detail",
        "created_at": "2015-02-05T05:32:48+0000",
        "updated_at": "2015-02-05T05:32:48+0000",
        "block": true,
        "target_branches": []
    },
    {
        "id": 15,
        "state": "pending",
        "target_url": "https://xxxx.com/push/check",
        "description": "check pending",
        "context": "jenkins/push",
        "detail": "commit check detail",
        "created_at": "2015-02-05T05:32:48+0000",
        "updated_at": "2015-02-05T05:32:48+0000",
        "block": false,
        "target_branches": []
    }
]
lastUpdate: 1/12/2026, 11:08:47 AM