流水线关联项目

This commit is contained in:
moshenglv
2021-01-19 11:52:29 +08:00
parent 05416339e5
commit f90bc0897b
6 changed files with 21 additions and 18 deletions

View File

@@ -5,12 +5,12 @@ class Ci::PipelinesController < Ci::BaseController
# ======流水线相关接口========== #
def list
@pipelines = Ci::Pipeline.where('login=? and project_id=?', current_user.login, params[:project_id])
@pipelines = Ci::Pipeline.where('login=? and identifier=?', current_user.login, params[:identifier])
end
def create
ActiveRecord::Base.transaction do
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name], login: current_user.login, project_id: params[:project_id])
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name], login: current_user.login, identifier: params[:identifier])
pipeline.save!
# 默认创建四个初始阶段

View File

@@ -28,20 +28,12 @@ class Ci::ProjectsController < Ci::BaseController
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, params[:owner], params.merge(identifier: @project.identifier))
if interactor.success?
@file = interactor.result
update_pipeline(params[:pipeline_id])
render_result(1, "更新成功")
else
render_error(interactor.error)
end
end
def update_pipeline(pipeline_id)
pipeline = Ci::Pipeline.find(pipeline_id)
if pipeline
pipeline.update!(sync: 1)
end
end
def activate
return render_error('你还未认证') unless current_user.ci_certification?

View File

@@ -94,11 +94,22 @@ class RepositoriesController < ApplicationController
if interactor.success?
@file = interactor.result
# create_new_pr(params)
#如果是更新流水线文件
if params[:pipeline_id]
update_pipeline(params[:pipeline_id])
end
else
render_error(interactor.error)
end
end
def update_pipeline(pipeline_id)
pipeline = Ci::Pipeline.find(pipeline_id)
if pipeline
pipeline.update!(sync: 1)
end
end
def update_file
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, params.merge(identifier: @project.identifier))
if interactor.success?