From d87fe501c4ca8a63342771f77b004cb4901e0173 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 6 Dec 2024 11:47:37 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E5=9B=BE=E5=BD=A2=E5=8C=96=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E5=A2=9E=E5=8A=A0=E5=88=86=E6=94=AF=E6=B5=81?= =?UTF-8?q?=E7=A8=8B-=E5=90=AF=E5=8A=A8=E8=8A=82=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/pipelines_controller.rb | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 66830d13c..68f15d152 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -92,24 +92,6 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_test_yaml) if @pipeline.blank? end - def build_pipeline_yaml(pipeline_name, pipeline_json) - if pipeline_json.present? && pipeline_json.present? - @pipeline_name = pipeline_name - params_nodes = pipeline_json["nodes"].select { |node| !["on-push", "on-schedule", "on-pull_request", "on-fork"].include?(node["name"]) } - on_nodes = pipeline_json["nodes"].select { |node| ["on-push", "on-schedule", "on-pull_request", "on-fork"].include?(node["name"]) } - @on_nodes = build_nodes(on_nodes) - @steps_nodes = build_nodes(params_nodes) - yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_pipeline.yaml.erb"))).result(binding) - # 删除空行内容 - pipeline_yaml = yaml.gsub(/^\s*\n/, "") - else - pipeline_yaml = params[:pipeline_yaml] - end - Rails.logger.info "pipeline_yaml=========================" - Rails.logger.info pipeline_yaml - pipeline_yaml - end - def build_pipeline_yaml_new(pipeline_name, pipeline_json) @pipeline_name = pipeline_name job_nodes = pipeline_json["nodes"].select { |node| node["data"]["name"].to_s.include?("job") } @@ -170,8 +152,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController node.label = input_node["data"]["label"] if input_node["data"]["label"].present? run_values = {} input_values = {} - if input_node["inputs"].present? - input_node["inputs"].each do |input| + if input_node["data"]["inputs"].present? + input_node["data"]["inputs"].each do |input| if input["name"].to_s.gsub("--", "") == "run" run_values = run_values.merge({ "#{input["name"].gsub("--", "")}": "#{input["value"]}" }) else @@ -331,7 +313,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController "name": "branches", "input_type": "input", "description": "分支名称,多个分支英文逗号隔开,如'master,dev'", - "is_required": true + "is_required": true, + "value": "master" }, { "id": 7,