Refactor AutoDevops pipeline logic into method
This commit is contained in:
parent
1ff339fad3
commit
78cee2c57b
1 changed files with 13 additions and 8 deletions
|
@ -10,14 +10,7 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
|
|||
if service.execute
|
||||
flash[:notice] = "Pipelines settings for '#{@project.name}' were successfully updated."
|
||||
|
||||
if service.run_auto_devops_pipeline?
|
||||
if @project.empty_repo?
|
||||
flash[:warning] = "This repository is currently empty. A new Auto DevOps pipeline will be created after a new file has been pushed to a branch."
|
||||
else
|
||||
CreatePipelineWorker.perform_async(project.id, current_user.id, project.default_branch, :web, ignore_skip_ci: true, save_on_errors: false)
|
||||
flash[:success] = "A new Auto DevOps pipeline has been created, go to <a href=\"#{project_pipelines_path(@project)}\">Pipelines page</a> for details".html_safe
|
||||
end
|
||||
end
|
||||
run_autodevops_pipeline(service)
|
||||
|
||||
redirect_to project_settings_ci_cd_path(@project)
|
||||
else
|
||||
|
@ -28,6 +21,18 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def run_autodevops_pipeline(service)
|
||||
return unless service.run_auto_devops_pipeline?
|
||||
|
||||
if @project.empty_repo?
|
||||
flash[:warning] = "This repository is currently empty. A new Auto DevOps pipeline will be created after a new file has been pushed to a branch."
|
||||
return
|
||||
end
|
||||
|
||||
CreatePipelineWorker.perform_async(project.id, current_user.id, project.default_branch, :web, ignore_skip_ci: true, save_on_errors: false)
|
||||
flash[:success] = "A new Auto DevOps pipeline has been created, go to <a href=\"#{project_pipelines_path(@project)}\">Pipelines page</a> for details".html_safe
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:project).permit(
|
||||
:runners_token, :builds_enabled, :build_allow_git_fetch,
|
||||
|
|
Loading…
Reference in a new issue