gitlab-org--gitlab-foss/lib/ci/api/runners.rb
Grzegorz Bizon 2ec93abed7 Merge branch 'master' into ci/persist-registration-token
* master: (66 commits)
  Fix runners admin view
  Fix migrations
  Rename mention of gitlab-git-http-server to gitlab-workhorse
  Bump Redis requirement to 2.8 for Sidekiq 4 requirements
  Fix wording on runner setup page
  add details on how to change saml button label
  Fix tests
  Move awards back to gray panel and few improvements to sidebar
  Few UI improvements to new sidebar implementation
  Fix tests for new issuable sidebar
  Update changelog
  Implement new sidebar for merge request page
  Make edit link on issuable sidebar works
  Redesign issue page for new sidebar
  Move awards css to separate file
  Implement issuable sidebar partial
  Update CHANGELOG
  Clarify cache behavior
  Run builds from projects with enabled CI
  Use Gitlab::Git instead of Ci::Git
  ...

Conflicts:
	db/schema.rb
2015-12-14 12:26:40 +01:00

58 lines
1.6 KiB
Ruby

module Ci
module API
# Runners API
class Runners < Grape::API
resource :runners do
# Delete runner
# Parameters:
# token (required) - The unique token of runner
#
# Example Request:
# GET /runners/delete
delete "delete" do
required_attributes! [:token]
authenticate_runner!
Ci::Runner.find_by_token(params[:token]).destroy
end
# Register a new runner
#
# Note: This is an "internal" API called when setting up
# runners, so it is authenticated differently.
#
# Parameters:
# token (required) - The unique token of runner
#
# Example Request:
# POST /runners/register
post "register" do
required_attributes! [:token]
runner =
if runner_registration_token_valid?
# Create shared runner. Requires admin access
Ci::Runner.create(
description: params[:description],
tag_list: params[:tag_list],
is_shared: true
)
elsif project = Project.find_by(runners_token: params[:token])
# Create a specific runner for project.
project.runners.create(
description: params[:description],
tag_list: params[:tag_list]
)
end
return forbidden! unless runner
if runner.id
present runner, with: Entities::Runner
else
not_found!
end
end
end
end
end
end