From d214b1ddae104bf91252e335e47cce45ebf9d265 Mon Sep 17 00:00:00 2001 From: victor <121183489011@qq.com> Date: Mon, 1 Feb 2021 13:40:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=A8=A1=E6=9D=BF=E5=90=8D=E7=A7=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ci/templates_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/ci/templates_controller.rb b/app/controllers/ci/templates_controller.rb index 11c6f2779..22998333e 100644 --- a/app/controllers/ci/templates_controller.rb +++ b/app/controllers/ci/templates_controller.rb @@ -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