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