构建流水线yaml,保存和更新,分支参数

This commit is contained in:
xxq250 2024-05-22 17:34:18 +08:00
parent 08fe69ca37
commit 4c956e48ae
1 changed files with 3 additions and 1 deletions

View File

@ -11,6 +11,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
tip_exception("已经存在#{params[:pipeline_name]}流水线!") if size > 0
@pipeline = Action::Pipeline.new(pipeline_name: params[:pipeline_name], project_id: @project.id)
@pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yaml"
@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?
@ -26,6 +27,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
def save_yaml
@pipeline = Action::Pipeline.new(pipeline_name: params[:pipeline_name], project_id: @project.id)
@pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yaml"
@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?
@ -128,7 +130,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
def get_pipeline_file_sha(file_name, branch)
file_path_uri = URI.parse(file_name)
interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: branch || 'master')
interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: branch || @project.default_branch)
if interactor.success?
file = interactor.result
file['sha']