Files
cnb/docs/api-groups/build/api.json
2026-01-16 13:03:57 +08:00

630 lines
16 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"swagger": "2.0",
"info": {
"title": "CNB OPENAPI",
"contact": {
"name": "Open API Support",
"url": "https://docs.cnb.cool/",
"email": "cnb@tencent.com"
},
"version": "1.0"
},
"paths": {
"/{repo}/-/build/crontab/sync/{branch}": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Build"
],
"summary": "同步仓库分支下的定时任务。 Synchronize the content under the repository branch.",
"operationId": "BuildCrontabSync",
"parameters": [
{
"type": "string",
"description": "repo",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Branch",
"name": "branch",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.BuildCommonResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:rw"
}
},
"/{repo}/-/build/logs": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Build"
],
"summary": "查询流水线构建列表。List pipeline builds.",
"operationId": "GetBuildLogs",
"parameters": [
{
"type": "string",
"description": "Repo path",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Start date in \"YYYY-MM-DD\" format, e.g. \"2024-12-01\"",
"name": "createTime",
"in": "query"
},
{
"type": "string",
"description": "End date in \"YYYY-MM-DD\" format, e.g. \"2024-12-01\"",
"name": "endTime",
"in": "query"
},
{
"type": "string",
"description": "Event name, e.g. \"push\"",
"name": "event",
"in": "query"
},
{
"type": "integer",
"description": "Pagination page number, default(1)",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "Pagination page size, default(30), max(100)",
"name": "pagesize",
"in": "query"
},
{
"type": "string",
"description": "Commit ID, e.g. \"2221d4535ec0c921bcd0858627c5025a871dd2b5\"",
"name": "sha",
"in": "query"
},
{
"type": "string",
"description": "Build SN, e.g. \"cnb-1qa-1i3f5ecau",
"name": "sn",
"in": "query"
},
{
"type": "string",
"description": "Source branch name, e.g. \"dev\"",
"name": "sourceRef",
"in": "query"
},
{
"type": "string",
"description": "Build status: \"pending\", \"success\", \"error\", \"cancel\"",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Target branch name, e.g. \"main\"",
"name": "targetRef",
"in": "query"
},
{
"type": "string",
"description": "User ID",
"name": "userId",
"in": "query"
},
{
"type": "string",
"description": "Username",
"name": "userName",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.BuildLogsResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:r"
}
},
"/{repo}/-/build/logs/stage/{sn}/{pipelineId}/{stageId}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Build"
],
"summary": "查询流水线Stage详情。Get pipeline build stage detail.",
"operationId": "GetBuildStage",
"parameters": [
{
"type": "string",
"description": "Repo path",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "SN",
"name": "sn",
"in": "path",
"required": true
},
{
"type": "string",
"description": "PipelineId",
"name": "pipelineId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "stageId",
"name": "stageId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.BuildStageResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:r"
}
},
"/{repo}/-/build/logs/{sn}": {
"delete": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Build"
],
"summary": "删除流水线日志内容。Delete pipeline logs content.",
"operationId": "BuildLogsDelete",
"parameters": [
{
"type": "string",
"description": "Repo path",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Sn",
"name": "sn",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.BuildCommonResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:rw"
}
},
"/{repo}/-/build/runner/download/log/{pipelineId}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"tags": [
"Build"
],
"summary": "流水线runner日志下载。Pipeline runner log download.",
"operationId": "BuildRunnerDownloadLog",
"parameters": [
{
"type": "string",
"description": "Repo path",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "PipelineId",
"name": "pipelineId",
"in": "path",
"required": true
}
],
"responses": {
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/die.WebError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/die.WebError"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:r"
}
},
"/{repo}/-/build/start": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Build"
],
"summary": "开始一个构建。Start a build.",
"operationId": "StartBuild",
"parameters": [
{
"type": "string",
"description": "repo",
"name": "repo",
"in": "path",
"required": true
},
{
"description": "Build params",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.StartBuildReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.BuildResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:rw"
}
},
"/{repo}/-/build/status/{sn}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Build"
],
"summary": "查询流水线构建状态。Get pipeline build status.",
"operationId": "GetBuildStatus",
"parameters": [
{
"type": "string",
"description": "Repo path",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "SN",
"name": "sn",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.BuildStatusResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:r"
}
},
"/{repo}/-/build/stop/{sn}": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"Build"
],
"summary": "停止一个构建。 Stop a build.",
"operationId": "StopBuild",
"parameters": [
{
"type": "string",
"description": "repo",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "SN",
"name": "sn",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.BuildResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-cnb-trigger:rw"
}
}
},
"definitions": {
"dto.BuildCommonResult": {
"type": "object",
"properties": {
"code": {
"description": "返回码0 表示成功1 表示失败",
"type": "integer"
},
"message": {
"description": "描述",
"type": "string"
}
}
},
"dto.BuildLogsResult": {
"type": "object",
"properties": {
"data": {
"description": "构建数据列表",
"type": "array",
"items": {
"$ref": "#/definitions/dto.LogInfo"
}
},
"init": {
"description": "当前仓库是否已经有构建记录1 表示有构建记录0 表示没有构建记录",
"type": "boolean"
},
"timestamp": {
"description": "当前时间戳",
"type": "integer"
},
"total": {
"description": "总数",
"type": "integer"
}
}
},
"dto.BuildStageResult": {
"type": "object",
"properties": {
"content": {
"description": "stage 日志内容,数组格式,一个元素表示一行日志",
"type": "array",
"items": {
"type": "string"
}
},
"duration": {
"description": "stage 耗时单位ms",
"type": "integer"
},
"endTime": {
"description": "stage 结束时间",
"type": "integer"
},
"error": {
"description": "stage 错误信息",
"type": "string"
},
"id": {
"description": "stage id",
"type": "string"
},
"name": {
"description": "stage 名称",
"type": "string"
},
"startTime": {
"description": "stage 开始时间",
"type": "integer"
},
"status": {
"description": "stage 状态: \"pending\", \"start\", \"success\", \"error\", \"cancel\", \"skipped\"",
"type": "string"
}
}
},
"die.WebError": {
"type": "object",
"properties": {
"errcode": {
"type": "integer"
},
"errmsg": {
"type": "string"
},
"errparam": {
"type": "object",
"additionalProperties": {}
}
}
},
"dto.StartBuildReq": {
"type": "object",
"properties": {
"branch": {
"description": "触发分支,默认为主分支",
"type": "string"
},
"config": {
"description": "指定配置文件内容yaml 格式",
"type": "string"
},
"env": {
"description": "环境变量,对象格式",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"event": {
"description": "事件名,必须是 api_trigger 或以 api_trigger_ 开头,默认为 `api_trigger`",
"type": "string"
},
"sha": {
"description": "commit id ,优先级比 tag 高,默认为分支最新提交记录",
"type": "string"
},
"sync": {
"description": "是否等待构建正式触发为false时会立刻返回 sn 和 buildLogUrl",
"type": "string"
},
"tag": {
"description": "触发 tag优先级比 branch 高",
"type": "string"
}
}
},
"dto.BuildResult": {
"type": "object",
"properties": {
"buildLogUrl": {
"description": "构建链接",
"type": "string"
},
"message": {
"description": "构建信息",
"type": "string"
},
"sn": {
"description": "构建号",
"type": "string"
},
"success": {
"description": "构建是否触发成功,不代表构建结果",
"type": "boolean"
}
}
},
"dto.BuildStatusResult": {
"type": "object",
"properties": {
"jsonConfig": {
"description": "解析后的流水线JSON格式配置内容",
"type": "string"
},
"pipelinesStatus": {
"description": "流水线的状态",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/dto.PipelineStatus"
}
},
"rawConfig": {
"description": "流水线原始配置内容",
"type": "string"
},
"status": {
"description": "构建状态",
"type": "string"
}
}
}
}
}