From a5e6594a37fa658f3d6bb911d57a6d793f32ed0b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 6 Dec 2024 11:36:29 +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=E7=A9=BA?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/pipelines_controller.rb | 2 -- app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index e080fdcdc..66830d13c 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -115,7 +115,6 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController job_nodes = pipeline_json["nodes"].select { |node| node["data"]["name"].to_s.include?("job") } on_nodes = pipeline_json["nodes"].select { |node| ["on-push", "on-schedule", "on-pull_request", "on-fork"].include?(node["data"]["name"]) } @on_nodes = build_nodes(on_nodes) - Rails.logger.info "111=========================#{@on_nodes}" @job_nodes = [] job_nodes.each do |job| node = Action::Node.find_by(name: job["data"]["name"]) @@ -128,7 +127,6 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController get_all_child_nodes(node, next_step_node) if next_step_node.present? @job_nodes.push(node) end - Rails.logger.info "222=========================#{@job_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/, "") Rails.logger.info "=========================" diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index aa170b071..ffd8ddf00 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -1,7 +1,7 @@ name: "<%=@pipeline_name %>" on: <%@on_nodes.each do |node| %> - <%if node.name.to_s.include?("on-push") %> + <%if node.name.to_s.include?("on-push") && node.input_values.present? %> push: <% node.input_values.each_key do |key| %> <%=key %>: @@ -14,7 +14,7 @@ on: <% end %> <% end %> <% end %> - <%if node.name.to_s.include?("on-pull_request") %> + <%if node.name.to_s.include?("on-pull_request") && node.input_values.present? %> pull_request: <% node.input_values.each_key do |key| %> <%=key %>: @@ -27,7 +27,7 @@ on: <% end %> <% end %> <% end %> - <%if node.name.to_s.include?("on-schedule") %> + <%if node.name.to_s.include?("on-schedule") && node.input_values.present? %> schedule: <% node.input_values.each_key do |key| %> - <%=key %>: "<%=node.input_values[key] %>"