From 78bcaf72fab7777c2f6ea6b8309d9a45251c826c Mon Sep 17 00:00:00 2001 From: daihw <928874202@qq.com> Date: Fri, 15 Jul 2022 16:57:57 +0800 Subject: [PATCH] feat: 043-pipeline-syntax --- 027-webhook-id-for-multi-triggers/proposal.md | 20 +- 029-approval-gateway/proposal.md | 6 +- 030-trigger-node/proposal.md | 5 +- 033-workflow&pipeline-post/proposal.md | 10 +- 043-pipeline-syntax/proposal.md | 218 ++++++++++++++++++ 5 files changed, 242 insertions(+), 17 deletions(-) create mode 100644 043-pipeline-syntax/proposal.md diff --git a/027-webhook-id-for-multi-triggers/proposal.md b/027-webhook-id-for-multi-triggers/proposal.md index 8aff4a4..1dad013 100644 --- a/027-webhook-id-for-multi-triggers/proposal.md +++ b/027-webhook-id-for-multi-triggers/proposal.md @@ -2,7 +2,7 @@ # 概述 -* 在项目DSL trigger声明中,增加id字段,用于配置webhook链接和定义多个trigger。 +* 在项目DSL trigger声明中,增加ref字段,用于配置webhook链接和定义多个trigger。 # 问题描述 @@ -12,9 +12,9 @@ # 约束条件 -* id为必填 -* id不能重复 -* id命名规则必须遵循[RFC 1035](https://datatracker.ietf.org/doc/html/rfc1035) ,如下: +* ref为必填 +* ref不能重复 +* ref命名规则必须遵循[RFC 1035](https://datatracker.ietf.org/doc/html/rfc1035) ,如下: * 最多 63 个字符 * 只能包含小写字母、数字,以及 '-' * 必须以字母开头 @@ -22,20 +22,24 @@ # 解决方案 -在`trigger`段落下添加`id`字段,由用户自定义webhook链接 +* 在`trigger`段落下添加`ref`字段,用于定义唯一标识,生成用户自定义webhook链接 + +* 在`trigger`段落下添加`name`字段,用于定义trigger节点名称,非必填。 语法: ``` trigger: - id: webhook-test + ref: webhook-test + name: webhook测试 type: webhook ``` 或 ``` trigger: - - id: webhook-test + - ref: webhook-test + name: webhook测试 type: webhook - - id: cron-test + - ref: cron-test type: cron ``` diff --git a/029-approval-gateway/proposal.md b/029-approval-gateway/proposal.md index 036ca7d..421bb1d 100644 --- a/029-approval-gateway/proposal.md +++ b/029-approval-gateway/proposal.md @@ -3,7 +3,7 @@ # 概述 -* 在项目DSL中的workflow/pipeline下添加`approval`内置节点,解决审批、手动输入参数的问题。 +* 在项目DSL中的workflow/pipeline下添加`approval`内置网关节点,解决审批、手动输入参数的问题。 # 问题描述 @@ -16,13 +16,13 @@ # 解决方案 -在workflow/pipeline下添加`approval`内置节点,执行到该节点时,节点和流程会挂起,等待用户审批后执行。 +在workflow/pipeline下添加`approval`内置网关节点,执行到该节点时,节点和流程会挂起,等待用户审批后执行。 该节点可配置输入参数`param`,由用户手动输入。 语法: ``` approval: - type: approval + gateway: approval param: # name为可选项,仅用于说明展示 - ref: username diff --git a/030-trigger-node/proposal.md b/030-trigger-node/proposal.md index 898a449..b8550f0 100644 --- a/030-trigger-node/proposal.md +++ b/030-trigger-node/proposal.md @@ -23,15 +23,14 @@ ``` # 当前项目: node: - type: trigger - id: trigger-test + trigger: trigger-test when: 表达式(可引用触发器参数、全局参数、所有节点输出参数) param: git_path: ${git_clone.git_path} # 被触发项目: trigger: - id: trigger-test + ref: trigger-test type: inner param: - ref: git_path diff --git a/033-workflow&pipeline-post/proposal.md b/033-workflow&pipeline-post/proposal.md index 32f9ba1..b296241 100644 --- a/033-workflow&pipeline-post/proposal.md +++ b/033-workflow&pipeline-post/proposal.md @@ -22,6 +22,8 @@ ``` global: post: + ref: feishu_notice + name: 飞书通知 type: feishu_notice_interactive:1.0.4 param: bot_webhook_url: ((feishu.webhook_url)) @@ -32,13 +34,15 @@ global: ``` global: post: - - type: feishu_notice_interactive:1.0.4 + - ref: feishu_notice + name: 飞书通知 + type: feishu_notice_interactive:1.0.4 param: bot_webhook_url: ((feishu.webhook_url)) msg_title: 标题 msg_markdown: 流程已结束,开始触发下一个流程 - - type: trigger - id: trigger-test + - ref: trigger-test + trigger: inner1 when: true param: git_path: ${git_clone.git_path} diff --git a/043-pipeline-syntax/proposal.md b/043-pipeline-syntax/proposal.md new file mode 100644 index 0000000..09e5622 --- /dev/null +++ b/043-pipeline-syntax/proposal.md @@ -0,0 +1,218 @@ + +# 概述 + +* 统一规范"管道定义"DSL语法。 + +# 问题描述 + +* 目前提出了一些rfc,大多对DSL有变动,需要整理所有变动后的"管道定义"DSL语法。 + +# 约束条件 + +无 + +# 解决方案 + +* 整理rfc,统一规范rfc变动后的"管道定义"DSL语法。 + +* 删除`global`下的`enabled`配置。 +```yaml +enabled: + value: true # 是否启用项目 + mutable: true # 是否只能修改DSL启用/禁用项目 +``` + +* `global`下的`concurrent`默认值由`false`改为`true`。 + +* 节点显示名称关键字由`alias`改为`name`。 +```yaml +pipeline: + - ref: feishu_notice + name: 飞书通知 +``` + +* 节点引用关键字由`type`改为`task`,节点ref和版本用`@`符号连接。 +```yaml +pipeline: + - ref: feishu_notice + name: 飞书通知 + task: feishu_notice_interactive@1.0.4 +``` + +* 节点定义输入参数关键字由`param`改为`input`。 +```yaml +pipeline: + - ref: git_clone + task: git_clone@1.2.3 + input: + remote_url: https://xxx/xxx +``` + +* shell节点定义环境变量关键字由`environment`改为`env`。 +```yaml +pipeline: + - ref: shell + image: alpine:3.13.6 + env: + AA: aa +``` + +DSL语法: + +```yaml +name: 构建建木CI Docker镜像 +description: 构建建木CI Docker镜像 + +trigger: + # cron + - ref: cron1 + name: cron1 + type: cron + schedule: 0 0 9 * * ? + # timer + - ref: timer1 + type: timer + start-at: 08:00:00 + repeat: true + interval: 1d + # inner + - ref: inner1 + type: inner + param: + - ref: username + name: git路径 + type: STRING + required: true + only: trigger.username === "张三" + # webhook + - ref: webhook1 + type: webhook + param: + - ref: gitee_ref + name: gitee_ref + type: STRING + value: body.json.ref + required: true + auth: + token: trigger.gitee_token + value: ((gitee.webhook_token)) + only: trigger.gitee_event === "Tag Push Hook" + +global: + tag: worker1 + cache: + - maven + concurrent: true # 默认为true + param: + - ref: image_name + name: 镜像名称 + type: STRING + value: jianmudev/jianmu-ci-server + - ref: maven_public_url + name: maven私库地址 + type: STRING + value: ext.maven_public_url + required: true + post: + - ref: trigger-inner + name: 内部触发 + trigger: inner2 + when: git_clone.git_branch === "master" + input: + git_path: shell.size + - ref: feishu + name: 飞书通知 + task: feishu_notice_interactive@1.0.4 + input: + bot_webhook_url: ((feishu.webhook_url)) + msg_title: 建木Deno表达式引擎Docker镜像构建完成 + msg_text: `标签:${git_clone.git_tag}\n\n镜像:${global.image_name}:${git_clone.git_tag}` + +pipeline: + - ref: git_clone + name: 克隆仓库 + task: git_clone@1.2.3 + timeout: 10m 20s + on-failure: + default: suspend + timeout: retry + max: 2 + input: + remote_url: https://gitee.com/jianmu-dev/jianmu-ci-server.git + ref: trigger.gitee_ref + - ref: shell + name: 查看仓库目录 + image: alpine:3.13.6 + env: + GIT_PATH: git_clone.git_path + script: + - cd $GIT_PATH + - export size=`du -sh | awk '{print $1}'` + output: + - ref: size + name: 仓库大小 + type: STRING + required: true + needs: + - git_clone + - ref: approval + name: 审批 + gateway: approval + input: + - ref: username + name: DockerHub用户名 + type: STRING + default: jianmudev + - ref: password + name: DockerHub密码 + type: SECRET + required: true + needs: + - git_clone + - ref: maven_jib_build + name: maven_jib构建镜像 + task: maven_build@1.3.1-jdk11 + cache: + maven: /.m2 + input: + mvn_action: install -Dmaven.test.skip=true + workspace: git_clone.git_path + image_name: global.image_name + image_tag: git_clone.git_branch + maven_public_url: global.maven_public_url + dockerhub_username: approval.username + dockerhub_password: approval.password + needs: + - shell + - approval + - ref: send_message + task: feishu_notice_interactive@1.0.4 + input: + bot_webhook_url: ((feishu.webhook_url)) + msg_title: 建木Deno表达式引擎Docker镜像构建完成 + msg_text: `标签:${git_clone.git_tag}\n\n镜像:${global.image_name}:${git_clone.git_tag}` + needs: + - maven_jib_build + - ref: trigger-inner2 + name: 内部触发 + trigger: inner3 + when: git_clone.git_branch === "master" + input: + git_path: shell.size + needs: + - send_message +``` + +# 待讨论问题 + +无 + +# 已解决问题 + +无 + +# 后果 + +无 + + -- Gitee