Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
319dfd68
Commit
319dfd68
authored
Feb 22, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'grapify-ci-runners-api' into 'master'
Grapify the CI::Runners API See merge request !9440
parents
12ac140a
3d013487
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
26 deletions
+18
-26
lib/ci/api/runners.rb
lib/ci/api/runners.rb
+18
-26
No files found.
lib/ci/api/runners.rb
View file @
319dfd68
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
desc
'Delete a runner'
params
do
requires
:token
,
type:
String
,
desc:
'The unique token of the runner'
end
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
desc
'Register a new runner'
do
success
Entities
::
Runner
end
params
do
requires
:token
,
type:
String
,
desc:
'The unique token of the runner'
optional
:description
,
type:
String
,
desc:
'The description of the runner'
optional
:tag_list
,
type:
Array
[
String
],
desc:
'A list of tags the runner should run for'
optional
:run_untagged
,
type:
Boolean
,
desc:
'Flag if the runner should execute untagged jobs'
optional
:locked
,
type:
Boolean
,
desc:
'Lock this runner for this specific project'
end
post
"register"
do
required_attributes!
[
:token
]
attributes
=
attributes_for_keys
(
[
:description
,
:tag_list
,
:run_untagged
,
:locked
]
)
runner_params
=
declared
(
params
,
include_missing:
false
)
runner
=
if
runner_registration_token_valid?
# Create shared runner. Requires admin access
Ci
::
Runner
.
create
(
attribute
s
.
merge
(
is_shared:
true
))
elsif
project
=
Project
.
find_by
(
runners_token:
params
[
:token
])
Ci
::
Runner
.
create
(
runner_param
s
.
merge
(
is_shared:
true
))
elsif
project
=
Project
.
find_by
(
runners_token:
runner_
params
[
:token
])
# Create a specific runner for project.
project
.
runners
.
create
(
attribute
s
)
project
.
runners
.
create
(
runner_param
s
)
end
return
forbidden!
unless
runner
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment