mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
fixed 节点数据提取后保存数据db
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||
before_action :require_operate_above
|
||||
before_action :require_operate_above, except: [:upload_results, :run_results]
|
||||
|
||||
def index
|
||||
@pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc)
|
||||
@@ -87,6 +87,31 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
||||
def upload_results
|
||||
tip_exception("参数错误") if params[:owner].blank? || params[:repo].blank? || params[:run_id].blank?
|
||||
@project, @owner = Project.find_with_namespace(params[:owner], params[:repo])
|
||||
tip_exception("项目不存在") if @project.blank?
|
||||
result = Action::PipelineResult.find_or_initialize_by(run_id: params[:run_id], project_id: @project.id)
|
||||
result.step_id = params[:step_id]
|
||||
result.job_name = params[:job_name]
|
||||
result.job_show_type = params[:job_show_type] || "html"
|
||||
result.job_result = params[:job_result]
|
||||
if result.save!
|
||||
render_ok
|
||||
else
|
||||
render_error("保存失败")
|
||||
end
|
||||
end
|
||||
|
||||
def run_results
|
||||
tip_exception("参数错误") if params[:owner].blank? || params[:repo].blank? || params[:run_id].blank?
|
||||
@project, @owner = Project.find_with_namespace(params[:owner], params[:repo])
|
||||
tip_exception("项目不存在") if @project.blank?
|
||||
results = Action::PipelineResult.where(run_id: params[:run_id], project_id: @project.id)
|
||||
render_ok(data: results.as_json(only: %i[id run_id job_name job_show_type job_result]))
|
||||
end
|
||||
|
||||
def show
|
||||
@pipeline = Action::Pipeline.find_by(id: params[:id])
|
||||
@pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_test_yaml) if @pipeline.blank?
|
||||
|
||||
25
app/models/action/pipeline_result.rb
Normal file
25
app/models/action/pipeline_result.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: action_pipeline_results
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# project_id :integer
|
||||
# run_id :integer
|
||||
# step_id :string(255)
|
||||
# job_name :string(255)
|
||||
# job_show_type :string(255)
|
||||
# job_result :text(65535)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_action_pipeline_results_on_project_id (project_id)
|
||||
# index_action_pipeline_results_on_run_id (run_id)
|
||||
#
|
||||
|
||||
class Action::PipelineResult < ApplicationRecord
|
||||
self.table_name = 'action_pipeline_results'
|
||||
belongs_to :project
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user