| @@ -100,14 +100,15 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| @job_nodes = [] | |||
| job_nodes.each do |job| | |||
| node = Action::Node.find_by(name: job["data"]["name"]) | |||
| next if node.blank? | |||
| node.label = job["data"]["label"] if job["data"]["label"].present? | |||
| node.node_id = job["data"]["id"] if job["data"]["id"].present? | |||
| next if node.blank? | |||
| next_edge_nodes = JSON.parse(demo2.to_json)["edges"].select { |edge| edge["source"]["cell"].include?(job["id"]) } | |||
| node_ids = next_edge_nodes.map { |t| t["target"]["cell"] } | |||
| next_step_node = JSON.parse(demo2.to_json)["nodes"].select { |node| node_ids.include?(node["data"]["id"]) && !node["data"]["name"].to_s.include?("job") }&.first | |||
| node.sub_nodes = [] | |||
| get_all_child_nodes(node, next_step_node) if next_step_node.present? | |||
| Rails.logger.info "node.sub_nodes=========================#{node.sub_nodes}" | |||
| @job_nodes.push(node) | |||
| end | |||
| yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_pipeline.yaml.erb"))).result(binding) | |||
| @@ -297,7 +298,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| }, | |||
| "id": "on-push-b2c871f", | |||
| "data": { | |||
| "id": 11, | |||
| "id": "on-push-b2c871f", | |||
| "label": "代码push事件启动", | |||
| "name": "on-push", | |||
| "full_name": "on-push", | |||
| @@ -324,14 +325,18 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "name": "paths-ignore", | |||
| "input_type": "input", | |||
| "description": "忽略文件,多个文件英文逗号隔开,如'**.md,**.yaml'", | |||
| "is_required": false | |||
| "is_required": false, | |||
| "value": "'*.md'" | |||
| } | |||
| ], | |||
| "x": 673, | |||
| "y": 495, | |||
| "img": "http://172.20.32.201:4000/api/attachments/c2f255e7-f359-4085-b5ce-1f05850ad74c" | |||
| "img": "http://172.20.32.201:4000/api/attachments/c2f255e7-f359-4085-b5ce-1f05850ad74c", | |||
| "branches": "master", | |||
| "paths-ignore": "'*.md'" | |||
| }, | |||
| "zIndex": 1, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -437,8 +442,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| }, | |||
| "id": "job-ed9ed25", | |||
| "data": { | |||
| "id": 29, | |||
| "label": "任务", | |||
| "id": "job-ed9ed25", | |||
| "label": "单元测试", | |||
| "name": "job", | |||
| "full_name": "", | |||
| "description": "允许并行多个任务", | |||
| @@ -456,6 +461,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "img": "" | |||
| }, | |||
| "zIndex": 2, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -561,8 +567,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| }, | |||
| "id": "job-3359fd2c", | |||
| "data": { | |||
| "id": 29, | |||
| "label": "任务", | |||
| "id": "job-3359fd2c", | |||
| "label": "压力测试", | |||
| "name": "job", | |||
| "full_name": "", | |||
| "description": "允许并行多个任务", | |||
| @@ -580,6 +586,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "img": "" | |||
| }, | |||
| "zIndex": 3, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -713,6 +720,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "run": "echo 111" | |||
| }, | |||
| "zIndex": 5, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -818,8 +826,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| }, | |||
| "id": "job-7760b89e", | |||
| "data": { | |||
| "id": 29, | |||
| "label": "任务", | |||
| "id": "job-7760b89e", | |||
| "label": "功能测试", | |||
| "name": "job", | |||
| "full_name": "", | |||
| "description": "允许并行多个任务", | |||
| @@ -837,6 +845,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "img": "" | |||
| }, | |||
| "zIndex": 4, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -970,6 +979,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "run": "echo 444" | |||
| }, | |||
| "zIndex": 7, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -1076,7 +1086,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "id": "shell-799aadee", | |||
| "data": { | |||
| "id": "shell-799aadee", | |||
| "label": "运行Shell脚本", | |||
| "label": "唱首歌", | |||
| "name": "shell", | |||
| "full_name": "shell", | |||
| "description": "", | |||
| @@ -1103,6 +1113,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "run": "echo 222" | |||
| }, | |||
| "zIndex": 6, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -1236,6 +1247,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "run": "echo 666" | |||
| }, | |||
| "zIndex": 9, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -1342,7 +1354,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "id": "shell-4e09400", | |||
| "data": { | |||
| "id": "shell-4e09400", | |||
| "label": "运行Shell脚本", | |||
| "label": "测试报告浏览", | |||
| "name": "shell", | |||
| "full_name": "shell", | |||
| "description": "", | |||
| @@ -1369,6 +1381,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "run": "echo 555" | |||
| }, | |||
| "zIndex": 8, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -1502,6 +1515,132 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| "run": "echo 333" | |||
| }, | |||
| "zIndex": 10, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| "name": "button-remove", | |||
| "args": { | |||
| "x": "100%", | |||
| "y": 0 | |||
| } | |||
| } | |||
| ] | |||
| } | |||
| }, | |||
| { | |||
| "position": { | |||
| "x": 1470, | |||
| "y": 560 | |||
| }, | |||
| "size": { | |||
| "width": 212, | |||
| "height": 48 | |||
| }, | |||
| "view": "react-shape-view", | |||
| "shape": "data-processing-dag-node", | |||
| "ports": { | |||
| "groups": { | |||
| "top": { | |||
| "position": { | |||
| "name": "top", | |||
| "args": { | |||
| "dx": 0 | |||
| } | |||
| }, | |||
| "attrs": { | |||
| "circle": { | |||
| "r": 4, | |||
| "magnet": true, | |||
| "strokeWidth": 1, | |||
| "fill": "#fff", | |||
| "stroke": "#85A5FF" | |||
| } | |||
| } | |||
| }, | |||
| "bottom": { | |||
| "position": { | |||
| "name": "bottom", | |||
| "args": { | |||
| "dx": 0 | |||
| } | |||
| }, | |||
| "attrs": { | |||
| "circle": { | |||
| "r": 4, | |||
| "magnet": true, | |||
| "strokeWidth": 1, | |||
| "fill": "#fff", | |||
| "stroke": "#85A5FF" | |||
| } | |||
| } | |||
| }, | |||
| "left": { | |||
| "position": "left", | |||
| "attrs": { | |||
| "circle": { | |||
| "r": 4, | |||
| "magnet": true, | |||
| "strokeWidth": 1, | |||
| "fill": "#fff", | |||
| "stroke": "#85A5FF" | |||
| } | |||
| } | |||
| }, | |||
| "right": { | |||
| "position": "right", | |||
| "attrs": { | |||
| "circle": { | |||
| "r": 4, | |||
| "magnet": true, | |||
| "strokeWidth": 1, | |||
| "fill": "#fff", | |||
| "stroke": "#85A5FF" | |||
| } | |||
| } | |||
| } | |||
| }, | |||
| "items": [ | |||
| { | |||
| "id": "checkout-gitlink-f6e67fe-left", | |||
| "group": "left" | |||
| }, | |||
| { | |||
| "id": "checkout-gitlink-f6e67fe-right", | |||
| "group": "right" | |||
| }, | |||
| { | |||
| "id": "checkout-gitlink-f6e67fe-top", | |||
| "group": "top" | |||
| }, | |||
| { | |||
| "id": "checkout-gitlink-f6e67fe-bottom", | |||
| "group": "bottom" | |||
| } | |||
| ] | |||
| }, | |||
| "id": "checkout-gitlink-f6e67fe", | |||
| "data": { | |||
| "id": "checkout-gitlink-f6e67fe", | |||
| "label": "加速版-克隆代码", | |||
| "name": "checkout-gitlink", | |||
| "full_name": "https://gitlink.org.cn/actions/checkout@v4", | |||
| "description": "", | |||
| "icon": "http://172.20.32.201:4000/api/attachments/c2f255e7-f359-4085-b5ce-1f05850ad74c", | |||
| "action_node_types_id": 6, | |||
| "yaml": "", | |||
| "sort_no": 0, | |||
| "use_count": 0, | |||
| "node_type": "step", | |||
| "is_mutil_link": false, | |||
| "link_type": "step", | |||
| "inputs": [], | |||
| "x": 2017, | |||
| "y": 887, | |||
| "img": "http://172.20.32.201:4000/api/attachments/c2f255e7-f359-4085-b5ce-1f05850ad74c" | |||
| }, | |||
| "zIndex": 11, | |||
| "isDelete": true, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| @@ -1857,6 +1996,44 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController | |||
| } | |||
| ] | |||
| } | |||
| }, | |||
| { | |||
| "shape": "data-processing-curve", | |||
| "inherit": "edge", | |||
| "connector": { | |||
| "name": "rounded", | |||
| "args": { | |||
| "radius": 10 | |||
| } | |||
| }, | |||
| "router": { | |||
| "name": "manhattan" | |||
| }, | |||
| "attrs": { | |||
| "line": { | |||
| "strokeDasharray": "0" | |||
| } | |||
| }, | |||
| "id": "cf60eaaf-3503-4c6e-96d8-ca8d273b107b", | |||
| "zIndex": -1, | |||
| "source": { | |||
| "cell": "shell-1766a765", | |||
| "port": "shell-1766a765-bottom" | |||
| }, | |||
| "target": { | |||
| "cell": "checkout-gitlink-f6e67fe", | |||
| "port": "checkout-gitlink-f6e67fe-top" | |||
| }, | |||
| "tools": { | |||
| "items": [ | |||
| { | |||
| "name": "button-remove", | |||
| "args": { | |||
| "distance": -40 | |||
| } | |||
| } | |||
| ] | |||
| } | |||
| } | |||
| ] | |||
| } | |||