fixed 图形化流水线增加分支流程-启动节点空处理

This commit is contained in:
xxq250 2024-12-06 11:36:29 +08:00
parent 131871dabb
commit a5e6594a37
2 changed files with 3 additions and 5 deletions

View File

@ -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") } 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 = pipeline_json["nodes"].select { |node| ["on-push", "on-schedule", "on-pull_request", "on-fork"].include?(node["data"]["name"]) }
@on_nodes = build_nodes(on_nodes) @on_nodes = build_nodes(on_nodes)
Rails.logger.info "111=========================#{@on_nodes}"
@job_nodes = [] @job_nodes = []
job_nodes.each do |job| job_nodes.each do |job|
node = Action::Node.find_by(name: job["data"]["name"]) 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? get_all_child_nodes(node, next_step_node) if next_step_node.present?
@job_nodes.push(node) @job_nodes.push(node)
end 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) 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/, "") pipeline_yaml = yaml.gsub(/^\s*\n/, "")
Rails.logger.info "=========================" Rails.logger.info "========================="

View File

@ -1,7 +1,7 @@
name: "<%=@pipeline_name %>" name: "<%=@pipeline_name %>"
on: on:
<%@on_nodes.each do |node| %> <%@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: push:
<% node.input_values.each_key do |key| %> <% node.input_values.each_key do |key| %>
<%=key %>: <%=key %>:
@ -14,7 +14,7 @@ on:
<% end %> <% end %>
<% end %> <% 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: pull_request:
<% node.input_values.each_key do |key| %> <% node.input_values.each_key do |key| %>
<%=key %>: <%=key %>:
@ -27,7 +27,7 @@ on:
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<%if node.name.to_s.include?("on-schedule") %> <%if node.name.to_s.include?("on-schedule") && node.input_values.present? %>
schedule: schedule:
<% node.input_values.each_key do |key| %> <% node.input_values.each_key do |key| %>
- <%=key %>: "<%=node.input_values[key] %>" - <%=key %>: "<%=node.input_values[key] %>"