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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e19aa50c
Commit
e19aa50c
authored
Mar 21, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support building all pipeline resource before saving
parent
46d910ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
30 deletions
+36
-30
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+2
-6
lib/gitlab/ci/pipeline/seed/base.rb
lib/gitlab/ci/pipeline/seed/base.rb
+4
-0
lib/gitlab/ci/pipeline/seed/build.rb
lib/gitlab/ci/pipeline/seed/build.rb
+12
-5
lib/gitlab/ci/pipeline/seed/stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+18
-19
No files found.
app/models/ci/pipeline.rb
View file @
e19aa50c
...
...
@@ -494,17 +494,13 @@ module Ci
# TODO specs
#
def
protected_ref?
strong_memoize
(
:protected_ref
)
do
project
.
protected_for?
(
ref
)
end
strong_memoize
(
:protected_ref
)
{
project
.
protected_for?
(
ref
)
}
end
# TODO specs
#
def
legacy_trigger
strong_memoize
(
:legacy_trigger
)
do
trigger_requests
.
first
end
strong_memoize
(
:legacy_trigger
)
{
trigger_requests
.
first
}
end
def
predefined_variables
...
...
lib/gitlab/ci/pipeline/seed/base.rb
View file @
e19aa50c
...
...
@@ -10,6 +10,10 @@ module Gitlab
def
excluded?
raise
NotImplementedError
end
def
to_resource
raise
NotImplementedError
end
end
end
end
...
...
lib/gitlab/ci/pipeline/seed/build.rb
View file @
e19aa50c
...
...
@@ -15,11 +15,18 @@ module Gitlab
end
def
attributes
@attributes
.
merge
(
project:
@pipeline
.
project
,
ref:
@pipeline
.
ref
,
tag:
@pipeline
.
tag
,
trigger_request:
@pipeline
.
legacy_trigger
,
protected:
@pipeline
.
protected_ref?
)
@attributes
.
merge
(
pipeline:
@pipeline
,
project:
@pipeline
.
project
,
ref:
@pipeline
.
ref
,
tag:
@pipeline
.
tag
,
trigger_request:
@pipeline
.
legacy_trigger
,
protected:
@pipeline
.
protected_ref?
)
end
def
to_resource
::
Ci
::
Build
.
new
(
attributes
)
end
end
end
...
...
lib/gitlab/ci/pipeline/seed/stage.rb
View file @
e19aa50c
...
...
@@ -3,41 +3,45 @@ module Gitlab
module
Pipeline
module
Seed
class
Stage
<
Seed
::
Base
attr_reader
:pipeline
delegate
:project
,
to: :pipeline
delegate
:size
,
to: :@builds
delegate
:size
,
to: :@seeds
def
initialize
(
pipeline
,
name
,
builds
)
@pipeline
=
pipeline
@name
=
name
@
buil
ds
=
builds
.
map
do
|
attributes
|
Seed
::
Build
.
new
(
pipeline
,
attributes
)
@
see
ds
=
builds
.
map
do
|
attributes
|
Seed
::
Build
.
new
(
@
pipeline
,
attributes
)
end
end
def
user
=
(
current_user
)
@
buil
ds
.
each
{
|
seed
|
seed
.
user
=
current_user
}
@
see
ds
.
each
{
|
seed
|
seed
.
user
=
current_user
}
end
def
attributes
{
name:
@name
,
p
roject:
project
}
{
name:
@name
,
p
ipeline:
@pipeline
,
project:
@pipeline
.
project
}
end
# TODO decouple from Seed::Build
# TODO decouple
#
def
builds_attributes
@builds
.
map
(
&
:attributes
)
@seeds
.
map
(
&
:attributes
)
end
def
to_resource
::
Ci
::
Stage
.
new
(
attributes
)
end
def
create!
pipeline
.
stages
.
build
(
attributes
)
.
tap
do
|
stage
|
builds_attributes
.
each
do
|
build_attributes
|
s
tage
.
builds
.
build
(
build_attributes
)
.
tap
do
|
build
|
build
.
pipeline
=
pipeline
to_resource
.
tap
do
|
stage
|
@seeds
.
each
do
|
seed
|
s
eed
.
to_resource
.
tap
do
|
build
|
stage
.
builds
<<
build
end
end
@pipeline
.
stages
<<
stage
stage
.
save!
stage
.
builds
.
each
do
|
build
|
...
...
@@ -45,11 +49,6 @@ module Gitlab
end
end
end
private
def
protected_ref?
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