From 3b04a592150f3cd01dfcc192acb770b1cc02f6be Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 17 Mar 2025 11:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/pipelines_controller.rb | 10 +--------- .../api/v1/projects/pipelines/create.json.jbuilder | 5 +++++ 2 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 app/views/api/v1/projects/pipelines/create.json.jbuilder diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 78b0b2e76..ebe1c109a 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -76,16 +76,8 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController @pipeline = Action::Pipeline.new(pipeline_name: params[:pipeline_name], project_id: @project.id) @pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yml" @pipeline.branch = params[:branch] || @project.default_branch - @pipeline.json = params[:pipeline_json].to_json - pipeline_yaml = build_pipeline_yaml(params[:pipeline_name], params[:pipeline_json]) - tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank? - @pipeline.yaml = pipeline_yaml + @pipeline.is_graphic_design = params[:pipeline_type] == 2 ? true : false @pipeline.save! - sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) - tip_exception("#{@pipeline.file_name}已存在") if sha - interactor = Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) - tip_exception(interactor.error) unless interactor.success? - render_ok({ id: @pipeline.id }) end def save_yaml diff --git a/app/views/api/v1/projects/pipelines/create.json.jbuilder b/app/views/api/v1/projects/pipelines/create.json.jbuilder new file mode 100644 index 000000000..d82015ade --- /dev/null +++ b/app/views/api/v1/projects/pipelines/create.json.jbuilder @@ -0,0 +1,5 @@ +json.status 0 +json.message "success" +json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, + :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at +# json.project \ No newline at end of file