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
9ad48a74
Commit
9ad48a74
authored
Oct 09, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract class responsible for building a pipeline
parent
8af29c21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
43 deletions
+68
-43
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+12
-43
lib/gitlab/ci/pipeline/chain/build.rb
lib/gitlab/ci/pipeline/chain/build.rb
+56
-0
No files found.
app/services/ci/create_pipeline_service.rb
View file @
9ad48a74
...
...
@@ -2,27 +2,24 @@ module Ci
class
CreatePipelineService
<
BaseService
attr_reader
:pipeline
SEQUENCE
=
[
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Abilities
,
SEQUENCE
=
[
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Build
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Abilities
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Repository
,
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Config
,
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
,
&
block
)
@pipeline
=
Ci
::
Pipeline
.
new
(
source:
source
,
project:
project
,
ref:
ref
,
sha:
sha
,
before_sha:
before_sha
,
tag:
tag_exists?
,
trigger_requests:
Array
(
trigger_request
),
user:
current_user
,
pipeline_schedule:
schedule
,
protected:
project
.
protected_for?
(
ref
)
)
command
=
OpenStruct
.
new
(
ignore_skip_ci:
ignore_skip_ci
,
@pipeline
=
Ci
::
Pipeline
.
new
command
=
OpenStruct
.
new
(
source:
source
,
origin_ref:
params
[
:ref
],
checkout_sha:
params
[
:checkout_sha
],
after_sha:
params
[
:after
],
before_sha:
params
[
:before
],
trigger_request:
trigger_request
,
schedule:
schedule
,
ignore_skip_ci:
ignore_skip_ci
,
save_incompleted:
save_on_errors
,
seeds_block:
block
,
project:
project
,
...
...
@@ -45,14 +42,6 @@ module Ci
private
def
commit
@commit
||=
project
.
commit
(
origin_sha
||
origin_ref
)
end
def
sha
commit
.
try
(
:id
)
end
def
update_merge_requests_head_pipeline
return
unless
pipeline
.
latest?
...
...
@@ -76,26 +65,6 @@ module Ci
.
created_or_pending
end
def
before_sha
params
[
:checkout_sha
]
||
params
[
:before
]
||
Gitlab
::
Git
::
BLANK_SHA
end
def
origin_sha
params
[
:checkout_sha
]
||
params
[
:after
]
end
def
origin_ref
params
[
:ref
]
end
def
tag_exists?
project
.
repository
.
tag_exists?
(
ref
)
end
def
ref
@ref
||=
Gitlab
::
Git
.
ref_name
(
origin_ref
)
end
def
pipeline_created_counter
@pipeline_created_counter
||=
Gitlab
::
Metrics
.
counter
(
:pipelines_created_total
,
"Counter of pipelines created"
)
...
...
lib/gitlab/ci/pipeline/chain/build.rb
0 → 100644
View file @
9ad48a74
module
Gitlab
module
Ci
module
Pipeline
module
Chain
class
Build
<
Chain
::
Base
include
Chain
::
Helpers
def
perform!
@pipeline
.
assign_attributes
(
source:
@command
.
source
,
project:
@project
,
ref:
ref
,
sha:
sha
,
before_sha:
before_sha
,
tag:
tag_exists?
,
trigger_requests:
Array
(
@command
.
trigger_request
),
user:
@current_user
,
pipeline_schedule:
@command
.
schedule
,
protected:
protected_ref?
)
end
def
break?
false
end
private
def
ref
@ref
||=
Gitlab
::
Git
.
ref_name
(
origin_ref
)
end
def
sha
@project
.
commit
(
origin_sha
||
origin_ref
).
try
(
:id
)
end
def
origin_ref
@command
.
origin_ref
end
def
origin_sha
@command
.
checkout_sha
||
@command
.
after_sha
end
def
before_sha
@command
.
checkout_sha
||
@command
.
before_sha
||
Gitlab
::
Git
::
BLANK_SHA
end
def
protected_ref?
@project
.
protected_for?
(
ref
)
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