云服务器内容精选

  • 操作步骤 登录流水线。 在流水线列表页搜索目标流水线,单击操作列。 弹出“执行配置”侧滑框,进行如下配置: 代码源:根据需要选择代码源的分支或标签执行配置。 运行参数配置:如果流水线配置了运行时参数,请根据需要设置参数值并保存,可参考参数使用。 执行阶段配置:流水线支持选择任务执行,可以选择一个或多个,默认执行全部任务。 阶段如果在配置时选择了“总是运行”,则该阶段的任务默认选中且不能取消。 执行描述:填写本次执行的调试信息。 配置完成后,单击“执行”,进入流水线执行详情页面,可实时查看流水线执行进展及任务执行状态。 单击右上角“停止”,可以中止任务执行。 流水线支持并发执行,继续单击“执行”,可以再次执行流水线,单条流水线最大支持同时执行的次数由购买套餐决定(体验版:1次;基础版:5次;专业版:10次;企业版:20次)。 执行完成后,即可查看流水线执行结果。
  • 请求示例 POST https://{endpoint}/v3/templates/task { "flow" : { "initial" : { "state_3" : "always" }, "state_3" : { "state_4" : "always" }, "state_4" : { "state_5" : "always", "Task_1" : "always", "Task_2" : "always" }, "state_5" : { "final" : "always" } }, "states" : { "initial" : { "type" : "stage", "name" : "initial", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Initial", "dsl_method" : "initial", "parameters" : { "display" : "hidden" }, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" }, "state_3" : { "type" : "stage", "name" : "state_3", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Source", "dsl_method" : "source", "parameters" : null, "params" : null, "is_manual_execution" : false, "execution_mode" : "parallel" }, "Task_1" : { "type" : "task", "name" : "Task_1", "module_or_template_id" : "00012", "module_or_template_name" : "Maven", "display_name" : "Build_Task", "dsl_method" : "buildJob", "parameters" : { "__repository__" : { "repo_name" : "fdfdfdf", "url" : "git@example.com:CloudPipelineTest-Copy00001/fdfdfdf.git" } }, "params" : null, "is_manual_execution" : false, "execution_mode" : null, "job_parameter_palidate" : true, "is_show_code_hub_url" : false, "is_execute" : true, "job_id" : "00012", "job_name" : "Maven", "project_id" : "4719b59466624abfbae0f83c3ce3a0dc" }, "Task_2" : { "type" : "task", "name" : "Task_2", "module_or_template_id" : "d7dffaefb6d94c63a09cf141668356c7", "module_or_template_name" : "codecheck_template", "display_name" : "Code_Check_Task", "dsl_method" : "codeCheck", "parameters" : { "language" : { "disable" : null, "name" : "Java", "display_name" : "Java", "id" : "782aade71ffb4ab780303555eb2e4825", "language" : "java" }, "codeBranch" : "master", "__repository__" : { "repo_name" : "fdfdfdf", "url" : "git@example.com:CloudPipelineTest-Copy00001/fdfdfdf.git" } }, "params" : null, "is_manual_execution" : false, "execution_mode" : null, "job_parameter_palidate" : true, "is_show_code_hub_url" : false, "is_execute" : true, "job_id" : "d7dffaefb6d94c63a09cf141668356c7", "job_name" : "codecheck_template", "project_id" : "4719b59466624abfbae0f83c3ce3a0dc" }, "state_4" : { "type" : "stage", "name" : "state_4", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Build_and_Check", "dsl_method" : "build", "parameters" : null, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" }, "state_5" : { "type" : "stage", "name" : "state_5", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Release", "dsl_method" : "release", "parameters" : null, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" }, "final" : { "type" : "stage", "name" : "final", "module_or_template_id" : null, "module_or_template_name" : null, "display_name" : "Final", "dsl_method" : "final", "parameters" : null, "params" : null, "is_manual_mxecution" : false, "execution_mode" : "parallel" } }, "workflow" : { "parameter" : [ { "name" : "serviceName", "value" : "pipeline-20201229165622", "description" : "this is a text type param", "paramtype" : "normalparam", "display_name" : null, "isStatic" : true, "isDefault" : true, "constraints" : null }, { "name" : "releaseVersion", "value" : "1.0.0", "description" : "this is a growth type param", "paramtype" : "growthparam", "display_name" : null, "isStatic" : false, "isDefault" : true, "constraints" : null } ], "source" : [ { "scmType" : "codehub", "codeHubName" : "fdfdfdf", "hookFlag" : false, "branches" : [ ], "defaultBranch" : "master", "branch" : "", "codeHubId" : "5224040", "gitUrl" : "git@example.com:CloudPipelineTest-Copy00001/fdfdfdf.git", "webUrl" : "https://example.com/codehub/project/bc97c4d99c7d4f98bb6cd104a77fddd6/codehub/140000127/home", "branchList" : [ "master" ] } ], "name" : "pipeline-123123", "description" : "", "project_id" : "bc97c4d99c7d4f98bb6cd104a77fddd6", "project_name" : "CloudPipelineTest-Copy" }, "changeInfo" : null }
  • 请求示例 获取流水线执行记录。 指定查询的起始偏移量为0,数量为10,开始时间戳为1677513600000,结束时间戳为1678118399000,并按照开始时间降序排序。 POST https://{endpoint}/v5/54f90b75fc1447b1b65e8d3a9f77923d/api/pipelines/e5460d1d403146a1935c2d4b68ef506c/pipeline-runs/list { "offset" : 0, "limit" : 10, "status" : [ "COMPLETED", "RUNNING", "FAILED", "CANCELED", "PAUSED", "SUSPEND", "QUEUED" ], "sort_key" : "start_time", "sort_dir" : "DESC", "start_time" : 1677513600000, "end_time" : 1678118399000 }
  • 响应示例 状态码: 200 OK { "offset" : 0, "limit" : 10, "total" : 1, "pipeline_runs" : [ { "pipeline_id" : "24949d4f4453495f8e5a76f993af7f43", "pipeline_run_id" : "ddb7532cb0e948f2af7bb4397fc19864", "executor_id" : "847a5317086c41798469d0868535943a", "executor_name" : "beta环境账号", "stage_status_list" : [ { "name" : "阶段_1", "sequence" : 0, "status" : "COMPLETED", "start_time" : "2023-03-06 10:04:46", "end_time" : "2023-03-06 10:04:46" } ], "status" : "COMPLETED", "run_number" : 11, "trigger_type" : "Manual", "build_params" : { "action" : null, "build_type" : "branch", "commit_id" : "990ea057751d299f5575aac25bf97e88a60b461e", "event_type" : "Manual", "merge_id" : null, "message" : "新建文件 Dockerfile", "source_branch" : null, "tag" : null, "target_branch" : "cloud_pipeline_release_1674026917209", "codehub_id" : "2111677704", "git_url" : "https://example.com/clsyz00001/aaaaa.git" }, "artifact_params" : null, "start_time" : 1678066487000, "end_time" : 1678066488000 } ] }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 offset Integer 起始偏移 limit Integer 查询大小 total Integer 总数 pipeline_runs Array of pipeline_runs objects 流水线运行信息 表5 pipeline_runs 参数 参数类型 描述 pipeline_id String 流水线ID pipeline_run_id String 流水线运行实例ID executor_id String 执行人ID executor_name String 执行人名称 stage_status_list Array of stage_status_list objects 阶段信息 status String 状态 run_number Integer 运行序号 trigger_type String 触发类型 build_params build_params object 构建参数 artifact_params artifact_params object 制品源参数 start_time Long 开始时间 end_time Long 结束时间 detail_url String 详情页地址 modify_url String 修改页地址 表6 stage_status_list 参数 参数类型 描述 name String 阶段名称 sequence Integer 序列号 status String 状态 start_time String 开始时间 end_time String 结束时间 id String 阶段ID 表7 build_params 参数 参数类型 描述 action String 合并请求事件类型 build_type String 基于分支还是tag触发 commit_id String 代码仓提交ID event_type String 运行事件类型 merge_id String 合并请求ID message String 代码仓提交信息 source_branch String 源分支 tag String 标签 target_branch String 目标分支 codehub_id String Repo代码仓ID git_url String 代码仓https地址 source_codehub_id String 源Repo代码仓ID source_codehub_url String 源Repo代码仓地址 source_codehub_http_url String 源Repo代码仓http地址 表8 artifact_params 参数 参数类型 描述 version String 包版本 branch_filter String 过滤分支 package_name String 包名称 organization String docker组织
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用 IAM 服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 表3 请求Body参数 参数 是否必选 参数类型 描述 status 否 Array of strings 状态 start_time 否 String 开始时间 end_time 否 String 结束时间 offset 否 Long 起始偏移 limit 否 Long 查询大小 sort_key 否 String 排序字段名称 sort_dir 否 String 排序规则
  • 请求示例 https://{endpoint}/v5/d80a8a6530324b7bac972cbb8a9f28ec/pipelines/e2bcbd561fbc4fd89577fb27c80b09a6/pipeline-runs/9e91b1fd7ce743b7a1b7a2458bcf76c7/jobs/6ce8600f396c4d5ba5290201ba9fd762/steps/7a1a7bb1b5e74d1c944d8b8971621033/logs { "start_offset" : 0, "end_offset" : 0, "limit" : 500, "sort" : "asc" }
  • 响应示例 状态码: 200 查询日志响应体 { "has_more" : false, "end_offset" : "25705", "start_offset" : "6132", "log" : "[2023/11/24 21:49:32.198 GMT+08:00] [INFO] [real_stage:执行Shell] : 该步骤开始执行。\n[2023/11/24 21:49:32.201 GMT+08:00] [INFO] [real_stage:执行Shell] : ================== start to do VmExecutionStep ==================\n[2023/11/24 21:49:32.207 GMT+08:00] [INFO] [real_stage:执行Shell] : [frame] start to send status data to service.\n[2023/11/24 21:49:32.225 GMT+08:00] [INFO] [real_stage:执行Shell] : [frame] finish to save status data to service.\n[2023/11/24 21:49:32.777 GMT+08:00] [INFO] [real_stage:执行Shell] : slave arch: amd64\n[2023/11/24 21:49:33.330 GMT+08:00] [INFO] [real_stage:执行Shell] : download file result: SUC CES S\n[2023/11/24 21:49:36.547 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== flow agent launched in [octopus_container] ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== use env job loader ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to do status callback\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] successfully callback to flow service\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] step begin: [1/1]-[执行Shell]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to use official executor [official_shell_plugin]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] ###############################@@@ 【step start】 @@@###############################\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== start to use script executor ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== start to execute shell pre function [make temp dir] ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== shell pre function [make temp dir] current temp dir:[/data/workspace/6ce8600f396c4d5ba5290201ba9fd762/7a1a7bb1b5e74d1c944d8b8971621033] ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== end to execute shell pre function [make temp dir] successfully ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== start to execute custom shell ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] 1\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== finish to use script executor with status success ===========\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] ################################@@@ 【step end】 @@@################################\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] finish to use official executor\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] step 执行Shell succeed. \n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to do data callback with context:[{1eaa92ecea2a42cab78e5269963a48c1 6ce8600f396c4d5ba5290201ba9fd762 7a1a7bb1b5e74d1c944d8b8971621033 0}]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] successfully callback to flow service\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] current step, duration time: [0.030766842]\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] start to do status callback\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] successfully callback to flow service\n[2023/11/24 21:49:36.548 GMT+08:00] [2023-11-24 21:49:36] [INFO] =========== flow agent end ===========\n[2023/11/24 21:49:36.563 GMT+08:00] [INFO] [real_stage:执行Shell] : [frame] start to send status data to service.\n[2023/11/24 21:49:36.563 GMT+08:00] [INFO] [real_stage:执行Shell] : 该步骤执行完成。", "location" : "jenkins", "step_run_id" : "7a1a7bb1b5e74d1c944d8b8971621033" }
  • URI POST /v5/{project_id}/api/pipelines/{pipeline_id}/pipeline-runs/{pipeline_run_id}/jobs/{job_run_id}/steps/{step_run_id}/logs 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID pipeline_id 是 String 流水线ID pipeline_run_id 是 String 流水线运行实例ID job_run_id 是 String 流水线任务ID step_run_id 是 String 流水线步骤ID
  • 请求示例 获取流水线列表。 指定查询的项目ID为”e12ed176898d4841aa9881fe9b933c87”,创建人ID为”847a5317086c41798469d0868535943a”,并根据流水线名称降序排序。 POST https://{endpoint}/v3/pipelines/list { "pipeline_name" : "", "project_ids" : "e12ed176898d4841aa9881fe9b933c87", "creator_ids" : "847a5317086c41798469d0868535943a", "executor_ids" : "847a5317086c41798469d0868535943a", "status" : "waiting,running,verifying,handling,suspending,completed", "outcome" : "error,success,aborted", "sort_key" : "pipeline_name", "sort_dir" : "desc", "git_url" : "", "offset" : 4, "limit" : 10 }
  • 响应示例 状态码: 200 OK { "offset" : 0, "limit" : 10, "total" : 88, "result" : [ { "project_id" : "e12ed176898d4841aa9881fe9b933c87", "project_name" : "Pipeline_Beta_自动测试", "pipeline_id" : "d33f98177c3e44f8841b005e1badcaed", "pipeline_name" : "马云多仓", "creator_id" : "847a5317086c41798469d0868535943a", "creator_name" : "大Beta测试账号", "executor_id" : "847a5317086c41798469d0868535943a", "executor_name" : "大Beta测试账号", "start_time" : "2022-09-08 17:08:02", "create_time" : "2022-07-28 17:02:11", "watched" : "true" }, { "project_id" : "e12ed176898d4841aa9881fe9b933c87", "project_name" : "Pipeline_Beta_自动测试", "pipeline_id" : "2ec08a45031c4d2896292a48b7fb1a30", "pipeline_name" : "门禁专用测试_勿删", "creator_id" : "847a5317086c41798469d0868535943a", "creator_name" : "大Beta测试账号", "executor_id" : "847a5317086c41798469d0868535943a", "executor_name" : "大Beta测试账号", "start_time" : "2022-09-08 16:52:03", "create_time" : "2020-10-29 17:05:02", "watched" : "true" } ] }
  • 请求参数 表1 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 表2 请求Body参数 参数 是否必选 参数类型 描述 pipeline_name 否 String 流水线名字。查询时进行模糊匹配。 project_ids 否 String 项目id,有多个值时用逗号分隔,id个数取值[0,10],非必选。如果该参数有值,则获取对应项目下的流水线列表;如果没有值,则获取用户有权限的所有项目的流水线列表 creator_ids 否 String 创建人id,有多个值时用逗号分隔,id个数取值[0,10],非必选 executor_ids 否 String 执行人id。有多个值时用逗号分隔,id个数取值[0,10],非必选 status 否 String 流水线运行状态.取值和含义:waiting:等待;running:执行中;verifying:待审核;suspending:挂起;completed:完成 outcome 否 String 流水线执行结果。取值及含义:success:成功;error:失败;aborted:终止 sort_key 否 String 用于排序的字段。取值为:pipeline_name,create_time,start_time sort_dir 否 String 排序方式。asc按排序字段升序,desc按排序字段降序 git_url 否 String 代码仓地址。仅支持codehub仓库,如:git@codehub.XXX.git offset 否 Integer 偏移量。表示从此偏移量开始查询,offset大于等于0,默认取值为0 limit 否 Integer 每次查询的条目数量。取值[10-50],默认取值为10
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 offset Integer 偏移量,表示从此偏移量开始查询,offset大于等于0 limit Integer 每次查询的条目数量 total Integer 总条目数量 result Array of PipelineBasicInfo objects 流水线列表 表4 PipelineBasicInfo 参数 参数类型 描述 project_id String 项目id project_name String 项目名称 pipeline_id String 流水线id pipeline_name String 流水线名称 creator_id String 流水线创建人id creator_name String 流水线创建人名字 executor_id String 流水线执行人id executor_name String 流水线执行人名字 start_time String 启动时间 create_time String 创建时间 watched String 用户是否关注流水线:true(关注),false(未关注) 状态码: 400 表5 响应Body参数 参数 参数类型 描述 error_msg String 错误信息 error_code String 错误码
  • 模板类型 流水线模板包括两种类型:系统模板和自定义模板。 模板列表操作说明如下: 操作项 说明 生成流水线,单击后进入“新建流水线”页面。 收藏模板,单击收藏模板,收藏成功后图标变为,再单击可以取消收藏。 单击后选择“编辑”,进入“任务编排”页面,可根据需要编辑模板。 单击后选择“复制”,进入“任务编排”页面,可根据需要复制模板。 单击后选择“删除”,可根据提示删除模板。 系统模板只能用来复制或生成流水线,不能编辑和删除。
  • 新建/配置模板 进入流水线模板列表。 单击模板列表“新建流水线模板”,进入“任务编排”页面。 根据需要配置模板基本信息、模板阶段/任务、模板参数等。 基本信息:可以编辑模板的名称(必填)、语言(可选择Java、Python、Node.js、Go等语言,默认选择“无”)、描述(非必填)。 流水线源:无需配置。 阶段准入:模板编排暂不支持配置阶段准入。 任务编排:流水线模板目前可以添加流水线阶段及部分插件,将构建、代码检查、部署、接口测试等任务配置在模板中后,通过模板创建流水线的时候会同步创建相应类型的任务。 参数设置:切换至“参数设置”页签,可根据需要为模板添加参数,流水线模板参数包括自定义参数和系统预定义参数两种,其中,自定义参数类型包括:字符串类型、枚举类型、自增长类型,配置方法请参见参数管理。 配置完所有信息,单击“保存”即可。