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
Jérome Perrin
gitlab-ce
Commits
48389e99
Commit
48389e99
authored
Jul 27, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pipeline
parent
19789154
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
21 deletions
+18
-21
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+18
-12
spec/services/ci/pipeline_trigger_service_spec.rb
spec/services/ci/pipeline_trigger_service_spec.rb
+0
-9
No files found.
app/services/ci/create_pipeline_service.rb
View file @
48389e99
module
Ci
module
Ci
class
CreatePipelineService
<
BaseService
class
CreatePipelineService
<
BaseService
class
ParameterValidationError
<
StandardError
end
class
InsufficientConditionError
<
StandardError
attr_reader
:pipeline
def
initialize
(
pipeline
)
@pipeline
=
pipeline
end
end
attr_reader
:pipeline
attr_reader
:pipeline
...
@@ -32,8 +38,8 @@ module Ci
...
@@ -32,8 +38,8 @@ module Ci
.
execute
(
pipeline
)
.
execute
(
pipeline
)
end
end
rescue
ParameterValida
tionError
=>
e
rescue
InsufficientCondi
tionError
=>
e
return
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
}
"
)
...
@@ -53,39 +59,39 @@ module Ci
...
@@ -53,39 +59,39 @@ 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?
raise
ParameterValida
tionError
,
error
(
'Pipeline is disabled'
)
raise
InsufficientCondi
tionError
,
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
)
raise
ParameterValida
tionError
,
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
raise
InsufficientCondi
tionError
,
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
else
else
raise
ParameterValida
tionError
,
error
(
'Insufficient permissions to create a new pipeline'
)
raise
InsufficientCondi
tionError
,
error
(
'Insufficient permissions to create a new pipeline'
)
end
end
end
end
unless
branch?
||
tag?
unless
branch?
||
tag?
raise
ParameterValida
tionError
,
error
(
'Reference not found'
)
raise
InsufficientCondi
tionError
,
error
(
'Reference not found'
)
end
end
unless
commit
unless
commit
raise
ParameterValida
tionError
,
error
(
'Commit not found'
)
raise
InsufficientCondi
tionError
,
error
(
'Commit not found'
)
end
end
unless
pipeline
.
config_processor
unless
pipeline
.
config_processor
unless
pipeline
.
ci_yaml_file
unless
pipeline
.
ci_yaml_file
raise
ParameterValida
tionError
,
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
raise
InsufficientCondi
tionError
,
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
end
end
raise
ParameterValida
tionError
,
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
raise
InsufficientCondi
tionError
,
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
end
end
if
!
ignore_skip_ci
&&
skip_ci?
if
!
ignore_skip_ci
&&
skip_ci?
pipeline
.
skip
if
save_on_errors
pipeline
.
skip
if
save_on_errors
r
eturn
pipeline
r
aise
InsufficientConditionError
,
pipeline
end
end
unless
pipeline
.
has_stage_seeds?
unless
pipeline
.
has_stage_seeds?
raise
ParameterValida
tionError
,
error
(
'No stages / jobs for this pipeline.'
)
raise
InsufficientCondi
tionError
,
error
(
'No stages / jobs for this pipeline.'
)
end
end
end
end
...
...
spec/services/ci/pipeline_trigger_service_spec.rb
View file @
48389e99
...
@@ -40,15 +40,6 @@ describe Ci::PipelineTriggerService, services: true do
...
@@ -40,15 +40,6 @@ describe Ci::PipelineTriggerService, services: true do
expect
(
result
[
:pipeline
].
variables
.
first
.
value
).
to
eq
(
variables
.
values
.
first
)
expect
(
result
[
:pipeline
].
variables
.
first
.
value
).
to
eq
(
variables
.
values
.
first
)
end
end
end
end
context
'when params have two variables and keys are duplicated'
do
let
(
:variables
)
{
[{
key:
'AAA'
,
value:
'AAA123'
},
{
key:
'AAA'
,
value:
'BBB123'
}]
}
it
'returns error'
do
expect
{
result
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
expect
(
result
[
:http_status
]).
to
eq
(
400
)
end
end
end
end
context
'when params have a non-existsed ref'
do
context
'when params have a non-existsed ref'
do
...
...
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