|
|
|
@@ -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? |
|
|
|
|