流水线保存接口
This commit is contained in:
parent
cf72921eb1
commit
3b04a59215
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue