diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/runners_controller.rb | 27 | ||||
-rw-r--r-- | app/models/runner.rb | 4 | ||||
-rw-r--r-- | app/views/layouts/project.html.haml | 4 | ||||
-rw-r--r-- | app/views/runners/_runner.html.haml | 25 | ||||
-rw-r--r-- | app/views/runners/index.html.haml | 31 | ||||
-rw-r--r-- | config/routes.rb | 2 |
7 files changed, 94 insertions, 0 deletions
@@ -1,6 +1,7 @@ v5.4 - Fixed 500 error for badge if build is pending - Non-admin users can now register specific runners for their projects + - Project specific runners page which users can access v5.3 - Remove annoying 'Done' message from schedule_builds cron job diff --git a/app/controllers/runners_controller.rb b/app/controllers/runners_controller.rb new file mode 100644 index 0000000..c1a732d --- /dev/null +++ b/app/controllers/runners_controller.rb @@ -0,0 +1,27 @@ +class RunnersController < ApplicationController + before_filter :authenticate_user! + before_filter :project + before_filter :authorize_access_project! + + layout 'project' + + def index + @runners = @project.runners.page(params[:page]).per(20) + end + + def destroy + @runner = @project.runners.find(params[:id]) + + if @runner.only_for?(@project) + @runner.destroy + end + + redirect_to project_runners_path(@project) + end + + protected + + def project + @project = Project.find(params[:project_id]) + end +end diff --git a/app/models/runner.rb b/app/models/runner.rb index d7b635d..4cb7615 100644 --- a/app/models/runner.rb +++ b/app/models/runner.rb @@ -37,4 +37,8 @@ class Runner < ActiveRecord::Base def shared? runner_projects.blank? end + + def only_for?(project) + projects == [project] + end end diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index 5780904..63d816f 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -38,6 +38,10 @@ = link_to project_web_hooks_path(@project) do %i.icon-link Web Hooks + = nav_link path: 'runners#index' do + = link_to project_runners_path(@project) do + %i.icon-cogs + Runners = nav_link path: 'projects#edit' do = link_to edit_project_path(@project) do %i.icon-edit diff --git a/app/views/runners/_runner.html.haml b/app/views/runners/_runner.html.haml new file mode 100644 index 0000000..a32c36d --- /dev/null +++ b/app/views/runners/_runner.html.haml @@ -0,0 +1,25 @@ +%tr{id: dom_id(runner)} + %td + = runner.id + %td + = runner.token.to_s + %td + .runner-description + = runner.description + %span (#{link_to 'edit', '#', class: 'edit-runner-link'}) + .runner-description-form.hide + = form_for [:admin, runner], remote: true, html: { class: 'form-inline' } do |f| + .form-group + = f.text_field :description, class: 'form-control' + = f.submit 'Save', class: 'btn' + %span (#{link_to 'cancel', '#', class: 'cancel'}) + %td + - if build = runner.builds.last + = link_to "##{build.id}", [build.project, build] + %td + #{time_ago_in_words(runner.created_at)} ago + %td + - if runner.only_for?(@project) + .pull-right + = link_to 'Remove', [@project, runner], data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-small' + diff --git a/app/views/runners/index.html.haml b/app/views/runners/index.html.haml new file mode 100644 index 0000000..e298905 --- /dev/null +++ b/app/views/runners/index.html.haml @@ -0,0 +1,31 @@ +%h3.project-title + Project specific runners + + .pull-right + %small + = pluralize(@runners.total_count, 'runner') +%hr +%p.lead + %span To register new runner you should enter the following registration token. With this token the runner will request a unique runner token and use that for future communication. + %code #{@project.token} + +.bs-callout + %p + A 'runner' is a process which runs a build. + You can setup as many runners as you need. + %br + Runners can be placed on separate users, servers, and even on your local machine. + %br + +%table.table + %thead + %tr + %th ID + %th Runner token + %th Description + %th Last build + %th Registered + %th + + = render @runners += paginate @runners diff --git a/config/routes.rb b/config/routes.rb index 70a5148..bca0bd1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,6 +39,8 @@ GitlabCi::Application.routes.draw do get :test end end + + resources :runners, only: [:index, :destroy] end resource :user_sessions |