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
e79ebabb
Commit
e79ebabb
authored
6 years ago
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Populate pipeline with objects before creating it
parent
6f20134d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
17 deletions
+47
-17
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-0
app/services/ci/pipeline_trigger_service.rb
app/services/ci/pipeline_trigger_service.rb
+4
-8
lib/gitlab/ci/pipeline/chain/create.rb
lib/gitlab/ci/pipeline/chain/create.rb
+0
-7
lib/gitlab/ci/pipeline/chain/populate.rb
lib/gitlab/ci/pipeline/chain/populate.rb
+32
-0
lib/gitlab/ci/pipeline/seed/stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+0
-2
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+10
-0
No files found.
app/services/ci/create_pipeline_service.rb
View file @
e79ebabb
...
@@ -7,6 +7,7 @@ module Ci
...
@@ -7,6 +7,7 @@ module Ci
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Repository
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Repository
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Config
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Config
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Skip
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Skip
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Populate
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Create
].
freeze
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Create
].
freeze
def
execute
(
source
,
ignore_skip_ci:
false
,
save_on_errors:
true
,
trigger_request:
nil
,
schedule:
nil
,
&
block
)
def
execute
(
source
,
ignore_skip_ci:
false
,
save_on_errors:
true
,
trigger_request:
nil
,
schedule:
nil
,
&
block
)
...
...
This diff is collapsed.
Click to expand it.
app/services/ci/pipeline_trigger_service.rb
View file @
e79ebabb
...
@@ -16,8 +16,8 @@ module Ci
...
@@ -16,8 +16,8 @@ module Ci
pipeline
=
Ci
::
CreatePipelineService
.
new
(
project
,
trigger
.
owner
,
ref:
params
[
:ref
])
pipeline
=
Ci
::
CreatePipelineService
.
new
(
project
,
trigger
.
owner
,
ref:
params
[
:ref
])
.
execute
(
:trigger
,
ignore_skip_ci:
true
)
do
|
pipeline
|
.
execute
(
:trigger
,
ignore_skip_ci:
true
)
do
|
pipeline
|
pipeline
.
trigger_requests
.
create!
(
trigger:
trigger
)
pipeline
.
trigger_requests
.
build
(
trigger:
trigger
)
create_pipeline_variables!
(
pipeline
)
pipeline
.
variables
.
build
(
variables
)
end
end
if
pipeline
.
persisted?
if
pipeline
.
persisted?
...
@@ -33,14 +33,10 @@ module Ci
...
@@ -33,14 +33,10 @@ module Ci
end
end
end
end
def
create_pipeline_variables!
(
pipeline
)
def
variables
return
unless
params
[
:variables
]
params
[
:variables
].
to_h
.
map
do
|
key
,
value
|
variables
=
params
[
:variables
].
map
do
|
key
,
value
|
{
key:
key
,
value:
value
}
{
key:
key
,
value:
value
}
end
end
pipeline
.
variables
.
create!
(
variables
)
end
end
end
end
end
end
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/pipeline/chain/create.rb
View file @
e79ebabb
...
@@ -9,13 +9,6 @@ module Gitlab
...
@@ -9,13 +9,6 @@ module Gitlab
::
Ci
::
Pipeline
.
transaction
do
::
Ci
::
Pipeline
.
transaction
do
pipeline
.
save!
pipeline
.
save!
@command
.
seeds_block
&
.
call
(
pipeline
)
pipeline
.
stage_seeds
.
each
do
|
seed
|
seed
.
user
=
current_user
seed
.
to_resource
.
save!
end
# TODO populate environments with find_or_initialize_by in the chain too.
# TODO populate environments with find_or_initialize_by in the chain too.
##
##
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/pipeline/chain/populate.rb
0 → 100644
View file @
e79ebabb
module
Gitlab
module
Ci
module
Pipeline
module
Chain
class
Populate
<
Chain
::
Base
PopulateError
=
Class
.
new
(
StandardError
)
def
perform!
##
# Populate pipeline with seeds block.
#
# It comes from a block argument to CreatePipelineService#execute.
#
@command
.
seeds_block
&
.
call
(
pipeline
)
pipeline
.
stage_seeds
.
each
do
|
seed
|
seed
.
user
=
current_user
pipeline
.
stages
<<
seed
.
to_resource
end
raise
Populate
::
PopulateError
if
pipeline
.
persisted?
end
def
break?
pipeline
.
persisted?
end
end
end
end
end
end
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/pipeline/seed/stage.rb
View file @
e79ebabb
...
@@ -37,8 +37,6 @@ module Gitlab
...
@@ -37,8 +37,6 @@ module Gitlab
stage
.
builds
<<
build
stage
.
builds
<<
build
end
end
end
end
@pipeline
.
stages
<<
stage
end
end
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
View file @
e79ebabb
...
@@ -79,5 +79,15 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
...
@@ -79,5 +79,15 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
expect
(
pipeline
.
stages
)
expect
(
pipeline
.
stages
)
.
to
all
(
satisfy
{
|
stage
|
stage
.
project
.
present?
})
.
to
all
(
satisfy
{
|
stage
|
stage
.
project
.
present?
})
end
end
it
'can not be persisted without explicit pipeline assignment'
do
stage
=
subject
.
to_resource
pipeline
.
save!
expect
(
stage
).
not_to
be_persisted
expect
(
pipeline
.
reload
.
stages
.
count
).
to
eq
0
expect
(
pipeline
.
reload
.
builds
.
count
).
to
eq
0
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