BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b8cf2a34
Commit
b8cf2a34
authored
May 06, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set run untagged option when registering a runner
parent
9ba72378
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
12 deletions
+38
-12
runners.rb
lib/ci/api/runners.rb
+6
-9
runners_spec.rb
spec/requests/ci/api/runners_spec.rb
+32
-3
No files found.
lib/ci/api/runners.rb
View file @
b8cf2a34
...
...
@@ -28,20 +28,17 @@ module Ci
post
"register"
do
required_attributes!
[
:token
]
attributes
=
{
description:
params
[
:description
],
tag_list:
params
[
:tag_list
],
run_untagged:
params
[
:run_untagged
]
||
true
}
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
)
Ci
::
Runner
.
create
(
attributes
.
merge
(
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
]
)
project
.
runners
.
create
(
attributes
)
end
return
forbidden!
unless
runner
...
...
spec/requests/ci/api/runners_spec.rb
View file @
b8cf2a34
...
...
@@ -15,13 +15,17 @@ describe Ci::API::API do
context
'when runner token is provided'
do
before
{
post
ci_api
(
"/runners/register"
),
token:
registration_token
}
it
'creates runner'
do
it
'creates runner
with default values
'
do
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
Ci
::
Runner
.
first
.
run_untagged
).
to
be
true
end
end
context
'when runner description is provided'
do
before
{
post
ci_api
(
"/runners/register"
),
token:
registration_token
,
description:
"server.hostname"
}
before
do
post
ci_api
(
"/runners/register"
),
token:
registration_token
,
description:
"server.hostname"
end
it
'creates runner'
do
expect
(
response
.
status
).
to
eq
(
201
)
...
...
@@ -30,7 +34,10 @@ describe Ci::API::API do
end
context
'when runner tags are provided'
do
before
{
post
ci_api
(
"/runners/register"
),
token:
registration_token
,
tag_list:
"tag1, tag2"
}
before
do
post
ci_api
(
"/runners/register"
),
token:
registration_token
,
tag_list:
"tag1, tag2"
end
it
'creates runner'
do
expect
(
response
.
status
).
to
eq
(
201
)
...
...
@@ -38,6 +45,28 @@ describe Ci::API::API do
end
end
context
'when option for running untagged jobs is provided'
do
context
'when tags are provided'
do
it
'creates runner'
do
post
ci_api
(
"/runners/register"
),
token:
registration_token
,
run_untagged:
false
,
tag_list:
[
'tag'
]
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
Ci
::
Runner
.
first
.
run_untagged
).
to
be
false
end
end
context
'when tags are not provided'
do
it
'does not create runner'
do
post
ci_api
(
"/runners/register"
),
token:
registration_token
,
run_untagged:
false
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
context
'when project token is provided'
do
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
before
{
post
ci_api
(
"/runners/register"
),
token:
project
.
runners_token
}
...
...
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