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
83df6384
Commit
83df6384
authored
May 05, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow runner to pick untagged build if configured
parent
2aa57071
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
11 deletions
+31
-11
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
spec/models/build_spec.rb
spec/models/build_spec.rb
+27
-11
No files found.
app/models/ci/build.rb
View file @
83df6384
...
...
@@ -290,6 +290,10 @@ module Ci
end
def
can_be_served?
(
runner
)
if
tag_list
.
empty?
&&
!
runner
.
run_untagged?
return
false
end
(
tag_list
-
runner
.
tag_list
).
empty?
end
...
...
spec/models/build_spec.rb
View file @
83df6384
...
...
@@ -259,11 +259,11 @@ describe Ci::Build, models: true do
end
describe
'#can_be_served?'
do
let
(
:runner
)
{
FactoryGirl
.
create
:ci_runner
}
let
(
:runner
)
{
create
(
:ci_runner
)
}
before
{
build
.
project
.
runners
<<
runner
}
context
'
runner without
tags'
do
context
'
when runner does not have
tags'
do
it
'can handle builds without tags'
do
expect
(
build
.
can_be_served?
(
runner
)).
to
be_truthy
end
...
...
@@ -274,23 +274,39 @@ describe Ci::Build, models: true do
end
end
context
'
runner with
tags'
do
context
'
when runner has
tags'
do
before
{
runner
.
tag_list
=
[
'bb'
,
'cc'
]
}
it
'can handle builds without tags'
do
expect
(
build
.
can_be_served?
(
runner
)).
to
be_truthy
end
shared_examples
'tagged build picker'
do
it
'can handle build with matching tags'
do
build
.
tag_list
=
[
'bb'
]
expect
(
build
.
can_be_served?
(
runner
)).
to
be_truthy
end
it
'cannot handle build with no
t matching tags'
do
it
'cannot handle build withou
t matching tags'
do
build
.
tag_list
=
[
'aa'
]
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
end
end
context
'when runner can pick untagged jobs'
do
it
'can handle builds without tags'
do
expect
(
build
.
can_be_served?
(
runner
)).
to
be_truthy
end
it_behaves_like
'tagged build picker'
end
context
'when runner can not pick untagged jobs'
do
before
{
runner
.
run_untagged
=
false
}
it
'can not handle builds without tags'
do
expect
(
build
.
can_be_served?
(
runner
)).
to
be_falsey
end
it_behaves_like
'tagged build picker'
end
end
end
describe
'#any_runners_online?'
do
...
...
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