Merge branch 'develop' of https://gitlink.org.cn/Trustie/forgeplus into develop
This commit is contained in:
commit
81da71d478
|
@ -14,12 +14,12 @@ class Ci::CloudAccountsController < Ci::BaseController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
flag, msg = check_bind_cloud_account!
|
flag, msg = check_bind_cloud_account!
|
||||||
return render_error(msg) if flag === true
|
return tip_exception(msg) if flag === true
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@cloud_account = bind_account!
|
@cloud_account = bind_account!
|
||||||
if @cloud_account.blank?
|
if @cloud_account.blank?
|
||||||
render_error('激活失败, 请检查你的云服务器信息是否正确.')
|
tip_exception('激活失败, 请检查你的云服务器信息是否正确.')
|
||||||
raise ActiveRecord::Rollback
|
raise ActiveRecord::Rollback
|
||||||
else
|
else
|
||||||
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
|
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
|
||||||
|
@ -27,17 +27,17 @@ class Ci::CloudAccountsController < Ci::BaseController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def activate
|
def activate
|
||||||
return render_error('请先认证') unless current_user.ci_certification?
|
return tip_exception('请先认证') unless current_user.ci_certification?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@cloud_account = Ci::CloudAccount.find params[:id]
|
@cloud_account = Ci::CloudAccount.find params[:id]
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
if @repo
|
if @repo
|
||||||
return render_error('该项目已经激活') if @repo.repo_active?
|
return tip_exception('该项目已经激活') if @repo.repo_active?
|
||||||
@repo.activate!(@project)
|
@repo.activate!(@project)
|
||||||
else
|
else
|
||||||
@repo = Ci::Repo.auto_create!(@ci_user, @project)
|
@repo = Ci::Repo.auto_create!(@ci_user, @project)
|
||||||
|
@ -50,7 +50,7 @@ class Ci::CloudAccountsController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,39 +59,39 @@ class Ci::CloudAccountsController < Ci::BaseController
|
||||||
|
|
||||||
def bind
|
def bind
|
||||||
flag, msg = check_bind_cloud_account!
|
flag, msg = check_bind_cloud_account!
|
||||||
return render_error(msg) if flag === true
|
return tip_exception(msg) if flag === true
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@cloud_account = bind_account!
|
@cloud_account = bind_account!
|
||||||
if @cloud_account.blank?
|
if @cloud_account.blank?
|
||||||
render_error('激活失败, 请检查你的云服务器信息是否正确.')
|
tip_exception('激活失败, 请检查你的云服务器信息是否正确.')
|
||||||
raise ActiveRecord::Rollback
|
raise ActiveRecord::Rollback
|
||||||
else
|
else
|
||||||
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
|
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def trustie_bind
|
def trustie_bind
|
||||||
account = params[:account].to_s
|
account = params[:account].to_s
|
||||||
return render_error("account不能为空.") if account.blank?
|
return tip_exception("account不能为空.") if account.blank?
|
||||||
|
|
||||||
flag, msg = check_trustie_bind_cloud_account!
|
flag, msg = check_trustie_bind_cloud_account!
|
||||||
return render_error(msg) if flag === true
|
return tip_exception(msg) if flag === true
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@cloud_account = trustie_bind_account!
|
@cloud_account = trustie_bind_account!
|
||||||
if @cloud_account.blank?
|
if @cloud_account.blank?
|
||||||
render_error('激活失败, 请检查你的云服务器信息是否正确.')
|
tip_exception('激活失败, 请检查你的云服务器信息是否正确.')
|
||||||
raise ActiveRecord::Rollback
|
raise ActiveRecord::Rollback
|
||||||
else
|
else
|
||||||
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
|
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unbind
|
def unbind
|
||||||
|
@ -107,18 +107,18 @@ class Ci::CloudAccountsController < Ci::BaseController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def oauth_grant
|
def oauth_grant
|
||||||
password = params[:password].to_s
|
password = params[:password].to_s
|
||||||
return render_error('你输入的密码不正确.') unless current_user.check_password?(password)
|
return tip_exception('你输入的密码不正确.') unless current_user.check_password?(password)
|
||||||
|
|
||||||
oauth = current_user.oauths.last
|
oauth = current_user.oauths.last
|
||||||
return render_error("服务器出小差了.") if oauth.blank?
|
return tip_exception("服务器出小差了.") if oauth.blank?
|
||||||
|
|
||||||
result = gitea_oauth_grant!(password, oauth)
|
result = gitea_oauth_grant!(password, oauth)
|
||||||
return render_error('授权失败.') unless result === true
|
return tip_exception('授权失败.') unless result === true
|
||||||
current_user.set_drone_step!(User::DEVOPS_CERTIFICATION)
|
current_user.set_drone_step!(User::DEVOPS_CERTIFICATION)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
size = Ci::Pipeline.where('branch=? and identifier=? and owner=?', params[:branch], params[:repo], params[:owner]).size
|
size = Ci::Pipeline.where('branch=? and identifier=? and owner=?', params[:branch], params[:repo], params[:owner]).size
|
||||||
if size > 0
|
if size > 0
|
||||||
render_error("#{params[:branch]}分支已经存在流水线!")
|
tip_exception("#{params[:branch]}分支已经存在流水线!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name],owner: params[:owner],
|
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name],owner: params[:owner],
|
||||||
|
@ -53,7 +53,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
render_ok({id: pipeline.id})
|
render_ok({id: pipeline.id})
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 在代码库创建文件
|
# 在代码库创建文件
|
||||||
|
@ -81,6 +81,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
repo_branch: pipeline.branch,
|
repo_branch: pipeline.branch,
|
||||||
repo_config: pipeline.file_name
|
repo_config: pipeline.file_name
|
||||||
}
|
}
|
||||||
|
Rails.logger.info("########create_params===#{create_params.to_json}")
|
||||||
repo = Ci::Repo.create_repo(create_params)
|
repo = Ci::Repo.create_repo(create_params)
|
||||||
repo
|
repo
|
||||||
end
|
end
|
||||||
|
@ -118,7 +119,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -132,7 +133,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def content
|
def content
|
||||||
|
@ -182,7 +183,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_stage
|
def update_stage
|
||||||
|
@ -192,7 +193,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_stage
|
def delete_stage
|
||||||
|
@ -205,7 +206,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_stage_index(pipeline_id, show_index, diff)
|
def update_stage_index(pipeline_id, show_index, diff)
|
||||||
|
@ -229,7 +230,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
unless steps.empty?
|
unless steps.empty?
|
||||||
steps.each do |step|
|
steps.each do |step|
|
||||||
unless step[:template_id]
|
unless step[:template_id]
|
||||||
render_error('请选择模板!')
|
tip_exception('请选择模板!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if !step[:id]
|
if !step[:id]
|
||||||
|
@ -246,7 +247,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_stage_step
|
def create_stage_step
|
||||||
|
@ -262,7 +263,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_stage_step
|
def update_stage_step
|
||||||
|
@ -279,7 +280,7 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_stage_step
|
def delete_stage_step
|
||||||
|
@ -289,6 +290,6 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,18 +30,18 @@ class Ci::ProjectsController < Ci::BaseController
|
||||||
@file = interactor.result
|
@file = interactor.result
|
||||||
render_result(1, "更新成功")
|
render_result(1, "更新成功")
|
||||||
else
|
else
|
||||||
render_error(interactor.error)
|
tip_exception(interactor.error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def activate
|
def activate
|
||||||
return render_error('你还未认证') unless current_user.ci_certification?
|
return tip_exception('你还未认证') unless current_user.ci_certification?
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
if @repo
|
if @repo
|
||||||
@repo.destroy! if @repo&.repo_user_id == 0
|
@repo.destroy! if @repo&.repo_user_id == 0
|
||||||
return render_error('该项目已经激活') if @repo.repo_active?
|
return tip_exception('该项目已经激活') if @repo.repo_active?
|
||||||
@repo.activate!(@project)
|
@repo.activate!(@project)
|
||||||
else
|
else
|
||||||
@repo = Ci::Repo.auto_create!(@ci_user, @project)
|
@repo = Ci::Repo.auto_create!(@ci_user, @project)
|
||||||
|
@ -55,12 +55,12 @@ class Ci::ProjectsController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def deactivate
|
def deactivate
|
||||||
return render_error('该项目已经取消激活') if !@repo.repo_active?
|
return tip_exception('该项目已经取消激活') if !@repo.repo_active?
|
||||||
|
|
||||||
@project.update_column(:open_devops, false)
|
@project.update_column(:open_devops, false)
|
||||||
@repo.deactivate_repos!
|
@repo.deactivate_repos!
|
||||||
|
|
|
@ -20,14 +20,14 @@ class Ci::SecretsController < Ci::BaseController
|
||||||
if result["id"]
|
if result["id"]
|
||||||
render_ok
|
render_ok
|
||||||
else
|
else
|
||||||
render_error(result["message"])
|
tip_exception(result["message"])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], options).create_secret
|
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], options).create_secret
|
||||||
if result["id"]
|
if result["id"]
|
||||||
render_ok
|
render_ok
|
||||||
else
|
else
|
||||||
render_error(result["message"])
|
tip_exception(result["message"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ class Ci::SecretsController < Ci::BaseController
|
||||||
Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], {name: name}).delete_secret
|
Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], {name: name}).delete_secret
|
||||||
render_ok
|
render_ok
|
||||||
else
|
else
|
||||||
render_error("参数名不能为空")
|
tip_exception("参数名不能为空")
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_ok
|
render_ok
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Ci::TemplatesController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -63,7 +63,7 @@ class Ci::TemplatesController < Ci::BaseController
|
||||||
)
|
)
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -73,7 +73,7 @@ class Ci::TemplatesController < Ci::BaseController
|
||||||
end
|
end
|
||||||
render_ok
|
render_ok
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
render_error(ex.message)
|
tip_exception(ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
#======流水线模板查询=====#
|
#======流水线模板查询=====#
|
||||||
|
|
|
@ -48,6 +48,10 @@ class Repository < ApplicationRecord
|
||||||
self.identifier.parameterize
|
self.identifier.parameterize
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def url
|
||||||
|
self['url'].blank? ? "#{Rails.application.config_for(:configuration)['platform_url']}/#{self.owner&.login}/#{self.identifier}.git" : self['url']
|
||||||
|
end
|
||||||
|
|
||||||
# with repository is mirror
|
# with repository is mirror
|
||||||
def set_mirror!
|
def set_mirror!
|
||||||
self.build_mirror(status: Mirror.statuses[:waiting]).save
|
self.build_mirror(status: Mirror.statuses[:waiting]).save
|
||||||
|
|
Loading…
Reference in New Issue