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
Boxiang Sun
gitlab-ce
Commits
ad61a181
Commit
ad61a181
authored
6 years ago
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support building all pipeline resource before saving
parent
ab0cd2a8
No related merge requests found
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 @
ad61a181
...
@@ -476,17 +476,13 @@ module Ci
...
@@ -476,17 +476,13 @@ module Ci
# TODO specs
# TODO specs
#
#
def
protected_ref?
def
protected_ref?
strong_memoize
(
:protected_ref
)
do
strong_memoize
(
:protected_ref
)
{
project
.
protected_for?
(
ref
)
}
project
.
protected_for?
(
ref
)
end
end
end
# TODO specs
# TODO specs
#
#
def
legacy_trigger
def
legacy_trigger
strong_memoize
(
:legacy_trigger
)
do
strong_memoize
(
:legacy_trigger
)
{
trigger_requests
.
first
}
trigger_requests
.
first
end
end
end
def
predefined_variables
def
predefined_variables
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/pipeline/seed/base.rb
View file @
ad61a181
...
@@ -10,6 +10,10 @@ module Gitlab
...
@@ -10,6 +10,10 @@ module Gitlab
def
excluded?
def
excluded?
raise
NotImplementedError
raise
NotImplementedError
end
end
def
to_resource
raise
NotImplementedError
end
end
end
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/pipeline/seed/build.rb
View file @
ad61a181
...
@@ -15,11 +15,18 @@ module Gitlab
...
@@ -15,11 +15,18 @@ module Gitlab
end
end
def
attributes
def
attributes
@attributes
.
merge
(
project:
@pipeline
.
project
,
@attributes
.
merge
(
ref:
@pipeline
.
ref
,
pipeline:
@pipeline
,
tag:
@pipeline
.
tag
,
project:
@pipeline
.
project
,
trigger_request:
@pipeline
.
legacy_trigger
,
ref:
@pipeline
.
ref
,
protected:
@pipeline
.
protected_ref?
)
tag:
@pipeline
.
tag
,
trigger_request:
@pipeline
.
legacy_trigger
,
protected:
@pipeline
.
protected_ref?
)
end
def
to_resource
::
Ci
::
Build
.
new
(
attributes
)
end
end
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/pipeline/seed/stage.rb
View file @
ad61a181
...
@@ -3,41 +3,45 @@ module Gitlab
...
@@ -3,41 +3,45 @@ module Gitlab
module
Pipeline
module
Pipeline
module
Seed
module
Seed
class
Stage
<
Seed
::
Base
class
Stage
<
Seed
::
Base
attr_reader
:pipeline
delegate
:size
,
to: :@seeds
delegate
:project
,
to: :pipeline
delegate
:size
,
to: :@builds
def
initialize
(
pipeline
,
name
,
builds
)
def
initialize
(
pipeline
,
name
,
builds
)
@pipeline
=
pipeline
@pipeline
=
pipeline
@name
=
name
@name
=
name
@
buil
ds
=
builds
.
map
do
|
attributes
|
@
see
ds
=
builds
.
map
do
|
attributes
|
Seed
::
Build
.
new
(
pipeline
,
attributes
)
Seed
::
Build
.
new
(
@
pipeline
,
attributes
)
end
end
end
end
def
user
=
(
current_user
)
def
user
=
(
current_user
)
@
buil
ds
.
each
{
|
seed
|
seed
.
user
=
current_user
}
@
see
ds
.
each
{
|
seed
|
seed
.
user
=
current_user
}
end
end
def
attributes
def
attributes
{
name:
@name
,
p
roject:
project
}
{
name:
@name
,
p
ipeline:
@pipeline
,
project:
@pipeline
.
project
}
end
end
# TODO decouple from Seed::Build
# TODO decouple
#
def
builds_attributes
def
builds_attributes
@builds
.
map
(
&
:attributes
)
@seeds
.
map
(
&
:attributes
)
end
def
to_resource
::
Ci
::
Stage
.
new
(
attributes
)
end
end
def
create!
def
create!
pipeline
.
stages
.
build
(
attributes
)
.
tap
do
|
stage
|
to_resource
.
tap
do
|
stage
|
builds_attributes
.
each
do
|
build_attributes
|
@seeds
.
each
do
|
seed
|
s
tage
.
builds
.
build
(
build_attributes
)
.
tap
do
|
build
|
s
eed
.
to_resource
.
tap
do
|
build
|
build
.
pipeline
=
pipeline
stage
.
builds
<<
build
end
end
end
end
@pipeline
.
stages
<<
stage
stage
.
save!
stage
.
save!
stage
.
builds
.
each
do
|
build
|
stage
.
builds
.
each
do
|
build
|
...
@@ -45,11 +49,6 @@ module Gitlab
...
@@ -45,11 +49,6 @@ module Gitlab
end
end
end
end
end
end
private
def
protected_ref?
end
end
end
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
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