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
07af37a2
Commit
07af37a2
authored
Jun 02, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not create pipeline objects when no builds
parent
53fe06ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
23 deletions
+34
-23
create_builds_service.rb
app/services/ci/create_builds_service.rb
+24
-17
create_commit_builds_service.rb
app/services/create_commit_builds_service.rb
+5
-5
create_builds_service_spec.rb
spec/services/ci/create_builds_service_spec.rb
+5
-1
No files found.
app/services/ci/create_builds_service.rb
View file @
07af37a2
...
...
@@ -20,26 +20,33 @@ module Ci
end
end
# don't create the same build twice
builds_attrs
.
reject!
do
|
build_attrs
|
@commit
.
builds
.
find_by
(
ref:
@commit
.
ref
,
tag:
@commit
.
tag
,
trigger_request:
trigger_request
,
name:
build_attrs
[
:name
])
end
builds_attrs
.
map
do
|
build_attrs
|
# don't create the same build twice
unless
@commit
.
builds
.
find_by
(
ref:
@commit
.
ref
,
tag:
@commit
.
tag
,
trigger_request:
trigger_request
,
name:
build_attrs
[
:name
])
build_attrs
.
slice!
(
:name
,
:commands
,
:tag_list
,
:options
,
:allow_failure
,
:stage
,
:stage_idx
)
build_attrs
.
slice!
(
:name
,
:commands
,
:tag_list
,
:options
,
:allow_failure
,
:stage
,
:stage_idx
)
build_attrs
.
merge!
(
ref:
@commit
.
ref
,
tag:
@commit
.
tag
,
trigger_request:
trigger_request
,
user:
user
,
project:
@commit
.
project
)
build_attrs
.
merge!
(
ref:
@commit
.
ref
,
tag:
@commit
.
tag
,
trigger_request:
trigger_request
,
user:
user
,
project:
@commit
.
project
)
@commit
.
builds
.
create!
(
build_attrs
)
end
##
# We do not persist new builds here.
# Those will be persisted when @commit is saved.
#
@commit
.
builds
.
new
(
build_attrs
)
end
end
end
...
...
app/services/create_commit_builds_service.rb
View file @
07af37a2
...
...
@@ -25,16 +25,16 @@ class CreateCommitBuildsService
return
false
end
# Create a new ci_commit
commit
.
save!
# Skip creating builds for commits that have [ci skip]
unless
commit
.
skip_ci?
# Create builds for commit
commit
.
create_builds
(
user
)
# Create builds for commit and
# skip saving pipeline when there are no builds
return
false
unless
commit
.
create_builds
(
user
)
end
commit
.
update_state!
# Create a new ci_commit
commit
.
save!
commit
end
end
spec/services/ci/create_builds_service_spec.rb
View file @
07af37a2
...
...
@@ -9,7 +9,7 @@ describe Ci::CreateBuildsService, services: true do
#
subject
do
described_class
.
new
(
commit
).
execute
(
commit
,
nil
,
user
,
status
)
described_class
.
new
(
commit
).
execute
(
'test'
,
user
,
status
,
nil
)
end
context
'next builds available'
do
...
...
@@ -17,6 +17,10 @@ describe Ci::CreateBuildsService, services: true do
it
{
is_expected
.
to
be_an_instance_of
Array
}
it
{
is_expected
.
to
all
(
be_an_instance_of
Ci
::
Build
)
}
it
'does not persist created builds'
do
expect
(
subject
.
first
).
not_to
be_persisted
end
end
context
'builds skipped'
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