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
8c4c310d
Commit
8c4c310d
authored
Jul 28, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Move validate to begin/rescue block"
This reverts commit 5ec3b63bfc6f341df040ae08be4858c7181bcacf.
parent
b59abf5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
25 deletions
+14
-25
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+14
-25
No files found.
app/services/ci/create_pipeline_service.rb
View file @
8c4c310d
module
Ci
module
Ci
class
CreatePipelineService
<
BaseService
class
CreatePipelineService
<
BaseService
class
InsufficientConditionError
<
StandardError
attr_reader
:pipeline
def
initialize
(
pipeline
)
@pipeline
=
pipeline
end
end
attr_reader
:pipeline
attr_reader
:pipeline
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
)
...
@@ -23,11 +15,13 @@ module Ci
...
@@ -23,11 +15,13 @@ module Ci
pipeline_schedule:
schedule
pipeline_schedule:
schedule
)
)
begin
result
=
validate
(
current_user
||
trigger_request
.
trigger
.
owner
,
validate
(
current_user
||
trigger_request
.
trigger
.
owner
,
ignore_skip_ci:
ignore_skip_ci
,
ignore_skip_ci:
ignore_skip_ci
,
save_on_errors:
save_on_errors
)
save_on_errors:
save_on_errors
)
return
result
if
result
begin
Ci
::
Pipeline
.
transaction
do
Ci
::
Pipeline
.
transaction
do
pipeline
.
save!
pipeline
.
save!
...
@@ -37,13 +31,8 @@ module Ci
...
@@ -37,13 +31,8 @@ module Ci
.
new
(
project
,
current_user
)
.
new
(
project
,
current_user
)
.
execute
(
pipeline
)
.
execute
(
pipeline
)
end
end
rescue
InsufficientConditionError
=>
e
return
e
.
pipeline
rescue
ActiveRecord
::
RecordInvalid
=>
e
rescue
ActiveRecord
::
RecordInvalid
=>
e
return
error
(
"Failed to persist the pipeline:
#{
e
}
"
)
return
error
(
"Failed to persist the pipeline:
#{
e
}
"
)
end
end
update_merge_requests_head_pipeline
update_merge_requests_head_pipeline
...
@@ -59,30 +48,30 @@ module Ci
...
@@ -59,30 +48,30 @@ module Ci
def
validate
(
triggering_user
,
ignore_skip_ci
:,
save_on_errors
:)
def
validate
(
triggering_user
,
ignore_skip_ci
:,
save_on_errors
:)
unless
project
.
builds_enabled?
unless
project
.
builds_enabled?
r
aise
InsufficientConditionError
,
error
(
'Pipeline is disabled'
)
r
eturn
error
(
'Pipeline is disabled'
)
end
end
unless
allowed_to_trigger_pipeline?
(
triggering_user
)
unless
allowed_to_trigger_pipeline?
(
triggering_user
)
if
can?
(
triggering_user
,
:create_pipeline
,
project
)
if
can?
(
triggering_user
,
:create_pipeline
,
project
)
r
aise
InsufficientConditionError
,
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
r
eturn
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
else
else
r
aise
InsufficientConditionError
,
error
(
'Insufficient permissions to create a new pipeline'
)
r
eturn
error
(
'Insufficient permissions to create a new pipeline'
)
end
end
end
end
unless
branch?
||
tag?
unless
branch?
||
tag?
r
aise
InsufficientConditionError
,
error
(
'Reference not found'
)
r
eturn
error
(
'Reference not found'
)
end
end
unless
commit
unless
commit
r
aise
InsufficientConditionError
,
error
(
'Commit not found'
)
r
eturn
error
(
'Commit not found'
)
end
end
unless
pipeline
.
config_processor
unless
pipeline
.
config_processor
unless
pipeline
.
ci_yaml_file
unless
pipeline
.
ci_yaml_file
r
aise
InsufficientConditionError
,
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
r
eturn
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
end
end
r
aise
InsufficientConditionError
,
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
r
eturn
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
end
end
if
!
ignore_skip_ci
&&
skip_ci?
if
!
ignore_skip_ci
&&
skip_ci?
...
@@ -91,7 +80,7 @@ module Ci
...
@@ -91,7 +80,7 @@ module Ci
end
end
unless
pipeline
.
has_stage_seeds?
unless
pipeline
.
has_stage_seeds?
r
aise
InsufficientConditionError
,
error
(
'No stages / jobs for this pipeline.'
)
r
eturn
error
(
'No stages / jobs for this pipeline.'
)
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