diff --git a/app/controllers/ci/pipelines_controller.rb b/app/controllers/ci/pipelines_controller.rb index 4cd7cf62..43b58e4c 100644 --- a/app/controllers/ci/pipelines_controller.rb +++ b/app/controllers/ci/pipelines_controller.rb @@ -1,13 +1,16 @@ -class Ci::PipelinesController < ApplicationController +class Ci::PipelinesController < Ci::BaseController + + before_action :require_login, only: %i[list create] + skip_before_action :connect_to_ci_db # ======流水线相关接口========== # def list - @pipelines = Ci::Pipeline.all + @pipelines = Ci::Pipeline.where('login=?', current_user.login) end def create ActiveRecord::Base.transaction do - pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name]) + pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name], login: current_user.login) pipeline.save! # 默认创建四个初始阶段 diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index c0c15838..842290d8 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -8,6 +8,7 @@ # created_at :datetime not null # updated_at :datetime not null # pipeline_status :string(50) default("unknown"), not null +# login :string(255) # class Ci::Pipeline < Ci::LocalBase diff --git a/app/models/ci/template.rb b/app/models/ci/template.rb index 34aab41d..e7be34a3 100644 --- a/app/models/ci/template.rb +++ b/app/models/ci/template.rb @@ -2,13 +2,14 @@ # # Table name: ci_templates # -# id :integer not null, primary key -# template_name :string(255) not null -# stage_type :string(255) not null -# category :string(255) not null -# content :text(65535) not null -# created_at :datetime not null -# updated_at :datetime not null +# id :integer not null, primary key +# template_name :string(255) not null +# stage_type :string(255) not null +# category :string(255) not null +# content :text(65535) not null +# created_at :datetime not null +# updated_at :datetime not null +# parent_category :string(255) # # Indexes # diff --git a/db/migrate/20210118011710_add_login_to_ci_pipelines.rb b/db/migrate/20210118011710_add_login_to_ci_pipelines.rb new file mode 100644 index 00000000..e1e914e5 --- /dev/null +++ b/db/migrate/20210118011710_add_login_to_ci_pipelines.rb @@ -0,0 +1,5 @@ +class AddLoginToCiPipelines < ActiveRecord::Migration[5.2] + def change + add_column :ci_pipelines, :login, :string + end +end