diff --git a/app/controllers/ob_repository_syncs_controller.rb b/app/controllers/ob_repository_syncs_controller.rb index d48cf1499..344a58355 100644 --- a/app/controllers/ob_repository_syncs_controller.rb +++ b/app/controllers/ob_repository_syncs_controller.rb @@ -48,6 +48,13 @@ class ObRepositorySyncsController < ApplicationController end def create_jobs + tip_exception "必须配置一个分支" if params[:github_branch].blank? && params[:gitee_branch].blank? && params[:gitlink_branch].blank? + ob_jobs = ObRepositorySyncJob.where(ob_repository_sync_id: @ob_repository_sync.id) + ob_jobs.where(job_type: params[:job_type]) if params[:job_type].present? + ob_jobs.where(github_branch: params[:github_branch]) if params[:github_branch].present? + ob_jobs.where(gitee_branch: params[:gitee_branch]) if params[:gitee_branch].present? + ob_jobs.where(gitlink_branch: params[:gitlink_branch]) if params[:gitlink_branch].present? + tip_exception "该分支组合已配置,不能重复!" if ob_jobs.count > 0 service = ObRepositorySync::ApiService.new(@ob_repository_sync.name) res = service.create_projects_jobs(params) tip_exception "保存失败: #{res["msg"]}" if res["code"].to_s != "200"