Browse Source

流水线初始化模板名称修改

tags/v3.0.1
victor 5 years ago
parent
commit
d214b1ddae
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      app/controllers/ci/templates_controller.rb

+ 10
- 0
app/controllers/ci/templates_controller.rb View File

@@ -79,9 +79,19 @@ class Ci::TemplatesController < Ci::BaseController
#======流水线模板查询=====#
def templates_by_stage
stage_type = params[:stage_type]
pipeline_id = params[:id]
if stage_type != Ci::PipelineStage::CUSTOMIZE_STAGE_TYPE
@templates = Ci::Template.where("stage_type = ?", stage_type)
@templates = @templates.select{ |template| template.login == current_user.login || template.login == 'admin'} unless current_user.admin?
if stage_type == Ci::PipelineStage::INIT_STAGE_TYPE && !@templates.nil?
@templates.each do |template|
content = template.content
unless content.blank?
pipeline = Ci::Pipeline.find(pipeline_id)
template.content = content.gsub(/{name}/, pipeline.pipeline_name) unless pipeline.nil?
end
end
end
# 根据模板类别分组
@category_templates = @templates.group_by{ |template| template.category }
else


Loading…
Cancel
Save