mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 21:26:07 +10:00
This solves https://dev.gitlab.org/gitlab/gitlabhq/issues/2646 1. This MR simplifies CI permission model: - read_build: allows to read a list of builds, artifacts and trace - update_build: allows to cancel and retry builds - admin_build: allows to manage triggers, runners and variables - read_commit_status: allows to read a list of commit statuses (including the status of a build, but doesn't allow to see a build details) - create_commit_status: allows to create a new commit status using API 2. I do make sure that the proper permissions are used in all places where the CI can be shown. 3. Add the `read_build` ability if user is anonymous or guest and allow_guest_to_access_builds is enabled. 4. Add CI setting: public_builds. 5. The artifacts specific permission are removed, since they are covered by `*_build`.
70 lines
1.7 KiB
Ruby
70 lines
1.7 KiB
Ruby
class Projects::RunnersController < Projects::ApplicationController
|
|
before_action :authorize_admin_build!
|
|
before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
|
|
|
|
layout 'project_settings'
|
|
|
|
def index
|
|
@runners = project.runners.ordered
|
|
@specific_runners = current_user.ci_authorized_runners.
|
|
where.not(id: project.runners).
|
|
ordered.page(params[:page]).per(20)
|
|
@shared_runners = Ci::Runner.shared.active
|
|
@shared_runners_count = @shared_runners.count(:all)
|
|
end
|
|
|
|
def edit
|
|
end
|
|
|
|
def update
|
|
if @runner.update_attributes(runner_params)
|
|
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
|
|
else
|
|
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if @runner.only_for?(project)
|
|
@runner.destroy
|
|
end
|
|
|
|
redirect_to runners_path(@project)
|
|
end
|
|
|
|
def resume
|
|
if @runner.update_attributes(active: true)
|
|
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
|
|
else
|
|
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
|
|
end
|
|
end
|
|
|
|
def pause
|
|
if @runner.update_attributes(active: false)
|
|
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
|
|
else
|
|
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
|
|
end
|
|
end
|
|
|
|
def show
|
|
end
|
|
|
|
def toggle_shared_runners
|
|
project.toggle!(:shared_runners_enabled)
|
|
|
|
redirect_to namespace_project_runners_path(project.namespace, project)
|
|
end
|
|
|
|
protected
|
|
|
|
def set_runner
|
|
@runner ||= project.runners.find(params[:id])
|
|
end
|
|
|
|
def runner_params
|
|
params.require(:runner).permit(:description, :tag_list, :active)
|
|
end
|
|
end
|