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
61dc0b7d
Commit
61dc0b7d
authored
Sep 26, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract pipeline persistence to a separate chain class
parent
7cfaccd6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
21 deletions
+39
-21
create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+10
-21
create.rb
lib/gitlab/ci/pipeline/chain/create.rb
+29
-0
No files found.
app/services/ci/create_pipeline_service.rb
View file @
61dc0b7d
...
...
@@ -3,9 +3,10 @@ module Ci
attr_reader
:pipeline
SEQUENCE
=
[
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Skip
].
freeze
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Skip
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Create
].
freeze
def
execute
(
source
,
ignore_skip_ci:
false
,
save_on_errors:
true
,
trigger_request:
nil
,
schedule:
nil
)
def
execute
(
source
,
ignore_skip_ci:
false
,
save_on_errors:
true
,
trigger_request:
nil
,
schedule:
nil
,
&
block
)
@pipeline
=
Ci
::
Pipeline
.
new
(
source:
source
,
project:
project
,
...
...
@@ -19,43 +20,31 @@ module Ci
protected:
project
.
protected_for?
(
ref
)
)
@pipeline
.
tap
do
|
pipeline
|
command
=
OpenStruct
.
new
(
ignore_skip_ci:
ignore_skip_ci
,
save_incompleted:
save_on_errors
,
trigger_request:
trigger_request
,
schedule:
schedule
,
seeds_block:
block
,
project:
project
,
current_user:
current_user
)
sequence
=
SEQUENCE
.
map
{
|
chain
|
chain
.
new
(
pipeline
,
command
)
}
done
=
sequence
.
any
?
do
|
chain
|
sequence_complete
=
sequence
.
none
?
do
|
chain
|
chain
.
perform!
chain
.
break?
end
update_merge_requests_head_pipeline
if
pipeline
.
persisted?
return
pipeline
if
done
begin
Ci
::
Pipeline
.
transaction
do
pipeline
.
save!
yield
(
pipeline
)
if
block_given?
Ci
::
CreatePipelineStagesService
.
new
(
project
,
current_user
)
.
execute
(
pipeline
)
end
rescue
ActiveRecord
::
RecordInvalid
=>
e
return
error
(
"Failed to persist the pipeline:
#{
e
}
"
)
end
update_merge_requests_head_pipeline
if
pipeline
.
persisted?
if
sequence_complete
cancel_pending_pipelines
if
project
.
auto_cancel_pending_pipelines?
pipeline_created_counter
.
increment
(
source:
source
)
pipeline
.
tap
(
&
:process!
)
pipeline
.
process!
end
end
end
private
...
...
lib/gitlab/ci/pipeline/chain/create.rb
0 → 100644
View file @
61dc0b7d
module
Gitlab
module
Ci
module
Pipeline
module
Chain
class
Create
<
Chain
::
Base
def
perform!
::
Ci
::
Pipeline
.
transaction
do
pipeline
.
save!
if
@command
.
seeds_block
@command
.
seeds_block
.
call
(
pipeline
)
end
::
Ci
::
CreatePipelineStagesService
.
new
(
project
,
current_user
)
.
execute
(
pipeline
)
end
rescue
ActiveRecord
::
RecordInvalid
=>
e
pipeline
.
erros
.
add
(
:base
,
"Failed to persist the pipeline:
#{
e
}
"
)
end
def
break?
!
pipeline
.
persisted?
end
end
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