Browse Source

流水线增加用户字段

tags/v3.0.1
moshenglv 5 years ago
parent
commit
2d99713cd0
4 changed files with 20 additions and 10 deletions
  1. +6
    -3
      app/controllers/ci/pipelines_controller.rb
  2. +1
    -0
      app/models/ci/pipeline.rb
  3. +8
    -7
      app/models/ci/template.rb
  4. +5
    -0
      db/migrate/20210118011710_add_login_to_ci_pipelines.rb

+ 6
- 3
app/controllers/ci/pipelines_controller.rb View File

@@ -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!

# 默认创建四个初始阶段


+ 1
- 0
app/models/ci/pipeline.rb View File

@@ -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


+ 8
- 7
app/models/ci/template.rb View File

@@ -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
#


+ 5
- 0
db/migrate/20210118011710_add_login_to_ci_pipelines.rb View File

@@ -0,0 +1,5 @@
class AddLoginToCiPipelines < ActiveRecord::Migration[5.2]
def change
add_column :ci_pipelines, :login, :string
end
end

Loading…
Cancel
Save