BigW Consortium Gitlab

pipelines_settings_controller.rb 1.22 KB
Newer Older
1 2 3 4
class Projects::PipelinesSettingsController < Projects::ApplicationController
  before_action :authorize_admin_pipeline!

  def show
5
    redirect_to project_settings_ci_cd_path(@project, params: params)
6 7 8
  end

  def update
9 10 11 12 13 14
    Projects::UpdateService.new(project, current_user, update_params).tap do |service|
      if service.execute
        flash[:notice] = "Pipelines settings for '#{@project.name}' were successfully updated."

        if service.run_auto_devops_pipeline?
          CreatePipelineWorker.perform_async(project.id, current_user.id, project.default_branch, :web, ignore_skip_ci: true, save_on_errors: false)
15
          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
16 17 18 19 20 21
        end

        redirect_to project_settings_ci_cd_path(@project)
      else
        render 'show'
      end
22 23 24 25 26 27 28
    end
  end

  private

  def update_params
    params.require(:project).permit(
29 30 31 32
      :runners_token, :builds_enabled, :build_allow_git_fetch,
      :build_timeout_in_minutes, :build_coverage_regex, :public_builds,
      :auto_cancel_pending_pipelines, :ci_config_path,
      auto_devops_attributes: [:id, :domain, :enabled]
33 34 35
    )
  end
end