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
8a444484
Commit
8a444484
authored
Jul 21, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract validations
parent
de01b862
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+24
-24
No files found.
app/services/ci/create_pipeline_service.rb
View file @
8a444484
...
...
@@ -15,12 +15,34 @@ module Ci
pipeline_schedule:
schedule
)
result
=
validate
(
current_user
||
trigger_request
.
trigger
.
owner
,
ignore_skip_ci:
ignore_skip_ci
,
save_on_errors:
save_on_errors
)
return
result
if
result
Ci
::
Pipeline
.
transaction
do
update_merge_requests_head_pipeline
if
pipeline
.
save
Ci
::
CreatePipelineStagesService
.
new
(
project
,
current_user
)
.
execute
(
pipeline
)
end
cancel_pending_pipelines
if
project
.
auto_cancel_pending_pipelines?
pipeline_created_counter
.
increment
(
source:
source
)
pipeline
.
tap
(
&
:process!
)
end
private
def
validate
(
triggering_user
,
ignore_skip_ci
:,
save_on_errors
:)
unless
project
.
builds_enabled?
return
error
(
'Pipeline is disabled'
)
end
triggering_user
=
current_user
||
trigger_request
.
trigger
.
owner
unless
allowed_to_trigger_pipeline?
(
triggering_user
)
if
can?
(
triggering_user
,
:create_pipeline
,
project
)
return
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
...
...
@@ -52,28 +74,6 @@ module Ci
unless
pipeline
.
has_stage_seeds?
return
error
(
'No stages / jobs for this pipeline.'
)
end
process!
do
pipeline_created_counter
.
increment
(
source:
source
)
end
end
private
def
process!
Ci
::
Pipeline
.
transaction
do
update_merge_requests_head_pipeline
if
pipeline
.
save
Ci
::
CreatePipelineStagesService
.
new
(
project
,
current_user
)
.
execute
(
pipeline
)
end
cancel_pending_pipelines
if
project
.
auto_cancel_pending_pipelines?
yield
pipeline
.
tap
(
&
:process!
)
end
def
allowed_to_trigger_pipeline?
(
triggering_user
)
...
...
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