fixed 调整job.id和依赖id
This commit is contained in:
parent
e6688d9214
commit
c472871355
|
@ -92,7 +92,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||||
tip_exception("参数错误") if params[:owner].blank? || params[:repo].blank? || params[:run_id].blank?
|
tip_exception("参数错误") if params[:owner].blank? || params[:repo].blank? || params[:run_id].blank?
|
||||||
@project, @owner = Project.find_with_namespace(params[:owner], params[:repo])
|
@project, @owner = Project.find_with_namespace(params[:owner], params[:repo])
|
||||||
tip_exception("项目不存在") if @project.blank?
|
tip_exception("项目不存在") if @project.blank?
|
||||||
result = Action::PipelineResult.find_or_initialize_by(run_id: params[:run_id], project_id: @project.id)
|
result = Action::PipelineResult.find_or_initialize_by(run_id: params[:run_id], step_id: params[:step_id], project_id: @project.id)
|
||||||
result.step_id = params[:step_id]
|
result.step_id = params[:step_id]
|
||||||
result.job_name = params[:job_name]
|
result.job_name = params[:job_name]
|
||||||
result.job_show_type = params[:job_show_type] || "html"
|
result.job_show_type = params[:job_show_type] || "html"
|
||||||
|
@ -131,6 +131,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||||
next_edge_nodes = pipeline_json["edges"].select { |edge| edge["source"]["cell"].include?(job["id"]) }
|
next_edge_nodes = pipeline_json["edges"].select { |edge| edge["source"]["cell"].include?(job["id"]) }
|
||||||
node_ids = next_edge_nodes.map { |t| t["target"]["cell"] }
|
node_ids = next_edge_nodes.map { |t| t["target"]["cell"] }
|
||||||
next_step_node = pipeline_json["nodes"].select { |node| node_ids.include?(node["id"]) && !node["data"]["name"].to_s.include?("job") }&.first
|
next_step_node = pipeline_json["nodes"].select { |node| node_ids.include?(node["id"]) && !node["data"]["name"].to_s.include?("job") }&.first
|
||||||
|
parent_node = pipeline_json["edges"].select { |edge| edge["target"]["cell"].include?(job["id"]) }.first
|
||||||
|
node.parent_node_id = parent_node.present? ? parent_node["source"]["cell"] : ""
|
||||||
node.sub_nodes = []
|
node.sub_nodes = []
|
||||||
get_all_child_nodes(pipeline_json, node, next_step_node) if next_step_node.present?
|
get_all_child_nodes(pipeline_json, node, next_step_node) if next_step_node.present?
|
||||||
@job_nodes.push(node)
|
@job_nodes.push(node)
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Action::Node < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :user, optional: true
|
belongs_to :user, optional: true
|
||||||
|
|
||||||
attr_accessor :cust_name, :run_values, :input_values, :sub_nodes, :link_type_array, :node_id
|
attr_accessor :cust_name, :run_values, :input_values, :parent_node_id, :sub_nodes, :link_type_array, :node_id
|
||||||
|
|
||||||
validates :name, presence: { message: "不能为空" }
|
validates :name, presence: { message: "不能为空" }
|
||||||
validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" }
|
validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" }
|
||||||
|
|
|
@ -37,12 +37,12 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
<%@job_nodes.each_with_index do |job,index| %>
|
<%@job_nodes.each_with_index do |job,index| %>
|
||||||
job<%=index + 1 %>:
|
<%=job.node_id %>:
|
||||||
name: "<%=job.label || job.name %>[<%=job.node_id %>]"
|
name: "<%=job.label || job.name %>[<%=job.node_id %>]"
|
||||||
# 运行环境,这里就是上面定义的多个 os
|
# 运行环境,这里就是上面定义的多个 os
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: 'ubuntu-latest'
|
||||||
<% if index >0 %>
|
<% if index >0 %>
|
||||||
needs: job<%=index %>
|
needs: <%=job.parent_node_id %>
|
||||||
<% end %>
|
<% end %>
|
||||||
steps:
|
steps:
|
||||||
<%job.sub_nodes.each do |node| %>
|
<%job.sub_nodes.each do |node| %>
|
||||||
|
|
Loading…
Reference in New Issue