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
Tatuya Kamada
gitlab-ce
Commits
3d013487
Commit
3d013487
authored
Feb 22, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grapify the CI::Runners API
parent
a7a08738
Changes
1
Hide 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 @
3d013487
module
Ci
module
Ci
module
API
module
API
# Runners API
class
Runners
<
Grape
::
API
class
Runners
<
Grape
::
API
resource
:runners
do
resource
:runners
do
# Delete runner
desc
'Delete a runner'
# Parameters:
params
do
# token (required) - The unique token of runner
requires
:token
,
type:
String
,
desc:
'The unique token of the runner'
#
end
# Example Request:
# GET /runners/delete
delete
"delete"
do
delete
"delete"
do
required_attributes!
[
:token
]
authenticate_runner!
authenticate_runner!
Ci
::
Runner
.
find_by_token
(
params
[
:token
]).
destroy
Ci
::
Runner
.
find_by_token
(
params
[
:token
]).
destroy
end
end
# Register a new runner
desc
'Register a new runner'
do
#
success
Entities
::
Runner
# Note: This is an "internal" API called when setting up
end
# runners, so it is authenticated differently.
params
do
#
requires
:token
,
type:
String
,
desc:
'The unique token of the runner'
# Parameters:
optional
:description
,
type:
String
,
desc:
'The description of the runner'
# token (required) - The unique token of 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'
# Example Request:
optional
:locked
,
type:
Boolean
,
desc:
'Lock this runner for this specific project'
# POST /runners/register
end
post
"register"
do
post
"register"
do
required_attributes!
[
:token
]
runner_params
=
declared
(
params
,
include_missing:
false
)
attributes
=
attributes_for_keys
(
[
:description
,
:tag_list
,
:run_untagged
,
:locked
]
)
runner
=
runner
=
if
runner_registration_token_valid?
if
runner_registration_token_valid?
# Create shared runner. Requires admin access
# Create shared runner. Requires admin access
Ci
::
Runner
.
create
(
attribute
s
.
merge
(
is_shared:
true
))
Ci
::
Runner
.
create
(
runner_param
s
.
merge
(
is_shared:
true
))
elsif
project
=
Project
.
find_by
(
runners_token:
params
[
:token
])
elsif
project
=
Project
.
find_by
(
runners_token:
runner_
params
[
:token
])
# Create a specific runner for project.
# Create a specific runner for project.
project
.
runners
.
create
(
attribute
s
)
project
.
runners
.
create
(
runner_param
s
)
end
end
return
forbidden!
unless
runner
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