debian-mirror-gitlab/app/controllers/projects/pipelines_controller.rb

59 lines
1.6 KiB
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
class Projects::PipelinesController < Projects::ApplicationController
before_action :pipeline, except: [:index, :new, :create]
before_action :commit, only: [:show]
before_action :authorize_read_pipeline!
before_action :authorize_create_pipeline!, only: [:new, :create]
before_action :authorize_update_pipeline!, only: [:retry, :cancel]
def index
@scope = params[:scope]
2016-09-29 09:46:39 +05:30
@pipelines = PipelinesFinder.new(project).execute(scope: @scope).page(params[:page]).per(30)
@running_or_pending_count = PipelinesFinder.new(project).execute(scope: 'running').count
@pipelines_count = PipelinesFinder.new(project).execute.count
2016-06-02 11:05:42 +05:30
end
def new
@pipeline = project.pipelines.new(ref: @project.default_branch)
2016-06-02 11:05:42 +05:30
end
def create
2016-09-13 17:45:13 +05:30
@pipeline = Ci::CreatePipelineService.new(project, current_user, create_params).execute(ignore_skip_ci: true, save_on_errors: false)
2016-06-02 11:05:42 +05:30
unless @pipeline.persisted?
render 'new'
return
end
redirect_to namespace_project_pipeline_path(project.namespace, project, @pipeline)
end
def show
end
def retry
pipeline.retry_failed(current_user)
2016-06-02 11:05:42 +05:30
redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project)
end
def cancel
pipeline.cancel_running
redirect_back_or_default default: namespace_project_pipelines_path(project.namespace, project)
end
private
def create_params
params.require(:pipeline).permit(:ref)
end
def pipeline
@pipeline ||= project.pipelines.find_by!(id: params[:id])
2016-06-02 11:05:42 +05:30
end
def commit
2016-06-22 15:30:34 +05:30
@commit ||= @pipeline.commit
2016-06-02 11:05:42 +05:30
end
end