流水线sha查询

This commit is contained in:
victor 2021-01-28 15:04:51 +08:00
parent c3136fc1a8
commit c3f69a48d6
1 changed files with 9 additions and 6 deletions

View File

@ -1,9 +1,9 @@
class Ci::PipelinesController < Ci::BaseController class Ci::PipelinesController < Ci::BaseController
before_action :require_login, only: %i[list create] before_action :require_login, only: %i[list create content]
skip_before_action :connect_to_ci_db, except: %i[list create destroy] skip_before_action :connect_to_ci_db, except: %i[list create destroy content]
before_action :load_project, only: %i[create] before_action :load_project, only: %i[create content]
before_action :load_repo, only: %i[create] before_action :load_repo, only: %i[create content]
# ======流水线相关接口========== # # ======流水线相关接口========== #
def list def list
@ -116,7 +116,7 @@ class Ci::PipelinesController < Ci::BaseController
def update def update
pipeline = Ci::Pipeline.find(params[:id]) pipeline = Ci::Pipeline.find(params[:id])
if pipeline if pipeline
pipeline.update!(pipeline_name: params[:pipeline_name]) pipeline.update!(pipeline_name: params[:pipeline_name],branch: params[:branch], event: params[:event])
end end
render_ok render_ok
rescue Exception => ex rescue Exception => ex
@ -140,7 +140,6 @@ class Ci::PipelinesController < Ci::BaseController
def content def content
@yaml = "\n" @yaml = "\n"
pipeline = Ci::Pipeline.find(params[:id]) pipeline = Ci::Pipeline.find(params[:id])
@sha = pipeline.sha
stages = pipeline.pipeline_stages stages = pipeline.pipeline_stages
if stages && !stages.empty? if stages && !stages.empty?
init_step = stages.first.pipeline_stage_steps.first init_step = stages.first.pipeline_stage_steps.first
@ -156,6 +155,10 @@ class Ci::PipelinesController < Ci::BaseController
end end
end end
end end
@sha = pipeline.sha
unless @sha
@sha = get_pipeline_file_sha(pipeline.file_name, pipeline.branch)
end
trigger = '' trigger = ''
trigger += " branch:\r\n - #{pipeline.branch}\r\n" unless pipeline.branch.blank? trigger += " branch:\r\n - #{pipeline.branch}\r\n" unless pipeline.branch.blank?
unless pipeline.event.blank? unless pipeline.event.blank?