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
6ff14634
Commit
6ff14634
authored
Jun 15, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve creating builds by combining two loops
parent
a76cbe52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
20 deletions
+16
-20
pipeline.rb
app/models/ci/pipeline.rb
+16
-20
No files found.
app/models/ci/pipeline.rb
View file @
6ff14634
...
...
@@ -91,16 +91,11 @@ module Ci
trigger_requests
.
any?
end
def
build_builds
(
user
,
trigger_request
=
nil
,
status
=
'success'
)
def
build_builds
(
user
,
trigger_request
=
nil
)
return
unless
config_processor
##
# Note that `Array#any?` implements a short circuit evaluation, so we
# build builds only for the first stage that has builds available.
#
config_processor
.
stages
.
any?
do
|
stage
|
build_builds_for_stage
(
stage
,
user
,
status
,
trigger_request
).
present?
end
build_builds_for_stages
(
config_processor
.
stages
,
user
,
'success'
,
trigger_request
)
end
def
create_builds
(
user
,
trigger_request
=
nil
)
...
...
@@ -122,17 +117,11 @@ module Ci
prior_builds
=
latest_builds
.
where
.
not
(
stage:
next_stages
)
prior_status
=
prior_builds
.
status
##
# Create builds for next stages based.
#
# Note that there is a short circult evaluation here.
#
have_builds
=
next_stages
.
any?
do
|
stage
|
build_builds_for_stage
(
stage
,
build
.
user
,
prior_status
,
build
.
trigger_request
).
present?
end
# build builds for next stage that has builds available
# and save pipeline if we have builds
build_builds_for_stages
(
next_stages
,
build
.
user
,
prior_status
,
build
.
trigger_request
)
&&
save
save!
if
have_builds
end
def
retried
...
...
@@ -179,8 +168,15 @@ module Ci
private
def
build_builds_for_stage
(
stage
,
user
,
status
,
trigger_request
)
CreateBuildsService
.
new
(
self
).
execute
(
stage
,
user
,
status
,
trigger_request
)
def
build_builds_for_stages
(
stages
,
user
,
status
,
trigger_request
)
##
# Note that `Array#any?` implements a short circuit evaluation, so we
# build builds only for the first stage that has builds available.
#
stages
.
any?
do
|
stage
|
CreateBuildsService
.
new
(
self
)
.
execute
(
stage
,
user
,
status
,
trigger_request
).
present?
end
end
def
update_state
...
...
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