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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
0367dbf0
Commit
0367dbf0
authored
Oct 05, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build pipelining
parent
5064c903
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
2 deletions
+68
-2
app/models/ci/build.rb
app/models/ci/build.rb
+3
-2
app/models/ci/commit.rb
app/models/ci/commit.rb
+10
-0
spec/models/ci/commit_spec.rb
spec/models/ci/commit_spec.rb
+55
-0
No files found.
app/models/ci/build.rb
View file @
0367dbf0
...
...
@@ -50,6 +50,7 @@ module Ci
scope
:latest
,
->
()
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
)).
order
(
stage_idx: :asc
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
scope
:for_ref
,
->
(
ref
)
{
where
(
ref:
ref
)
}
scope
:similar
,
->
(
build
)
{
where
(
ref:
build
.
ref
,
tag:
build
.
tag
,
trigger_request_id:
build
.
trigger_request_id
)
}
acts_as_taggable
...
...
@@ -125,8 +126,8 @@ module Ci
Ci
::
WebHookService
.
new
.
build_end
(
build
)
end
if
build
.
commit
.
s
uccess?
build
.
commit
.
create_next_builds
(
build
.
trigger_request
)
if
build
.
commit
.
s
hould_create_next_builds?
(
build
)
build
.
commit
.
create_next_builds
(
build
.
ref
,
build
.
tag
,
build
.
user
,
build
.
trigger_request
)
end
project
.
execute_services
(
build
)
...
...
app/models/ci/commit.rb
View file @
0367dbf0
...
...
@@ -224,6 +224,16 @@ module Ci
update!
(
committed_at:
DateTime
.
now
)
end
def
should_create_next_builds?
(
build
)
# don't create other builds if this one is retried
other_builds
=
builds
.
similar
(
build
).
latest
return
false
unless
other_builds
.
include?
(
build
)
other_builds
.
all?
do
|
build
|
build
.
success?
||
build
.
ignored?
end
end
private
def
save_yaml_error
(
error
)
...
...
spec/models/ci/commit_spec.rb
View file @
0367dbf0
...
...
@@ -215,4 +215,59 @@ describe Ci::Commit do
expect
(
commit
.
coverage
).
to
be_nil
end
end
describe
:should_create_next_builds?
do
before
do
@build1
=
FactoryGirl
.
create
:ci_build
,
commit:
commit
,
name:
'build1'
,
ref:
'master'
,
tag:
false
,
status: :success
@build2
=
FactoryGirl
.
create
:ci_build
,
commit:
commit
,
name:
'build1'
,
ref:
'develop'
,
tag:
false
,
status: :failed
@build3
=
FactoryGirl
.
create
:ci_build
,
commit:
commit
,
name:
'build1'
,
ref:
'master'
,
tag:
true
,
status: :failed
@build4
=
FactoryGirl
.
create
:ci_build
,
commit:
commit
,
name:
'build4'
,
ref:
'master'
,
tag:
false
,
status: :success
end
context
'for success'
do
it
'to create if all succeeded'
do
expect
(
commit
.
should_create_next_builds?
(
@build4
)).
to
be_truthy
end
end
context
'for failed'
do
before
do
@build4
.
update_attributes
(
status: :failed
)
end
it
'to not create'
do
expect
(
commit
.
should_create_next_builds?
(
@build4
)).
to
be_falsey
end
context
'and ignore failures for current'
do
before
do
@build4
.
update_attributes
(
allow_failure:
true
)
end
it
'to create'
do
expect
(
commit
.
should_create_next_builds?
(
@build4
)).
to
be_truthy
end
end
end
context
'for running'
do
before
do
@build4
.
update_attributes
(
status: :running
)
end
it
'to not create'
do
expect
(
commit
.
should_create_next_builds?
(
@build4
)).
to
be_falsey
end
end
context
'for retried'
do
before
do
@build5
=
FactoryGirl
.
create
:ci_build
,
commit:
commit
,
name:
'build4'
,
ref:
'master'
,
tag:
false
,
status: :failed
end
it
'to not create'
do
expect
(
commit
.
should_create_next_builds?
(
@build4
)).
to
be_falsey
end
end
end
end
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