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
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
class
CreatePipelineService
<
BaseService
class
ParameterValidationError
<
StandardError
end
class
InsufficientConditionError
<
StandardError
attr_reader
:pipeline
def
initialize
(
pipeline
)
@pipeline
=
pipeline
end
end
attr_reader
:pipeline
...
...
@@ -32,8 +38,8 @@ module Ci
.
execute
(
pipeline
)
end
rescue
ParameterValida
tionError
=>
e
return
e
rescue
InsufficientCondi
tionError
=>
e
return
e
.
pipeline
rescue
ActiveRecord
::
RecordInvalid
=>
e
return
error
(
"Failed to persist the pipeline:
#{
e
}
"
)
...
...
@@ -53,39 +59,39 @@ module Ci
def
validate
(
triggering_user
,
ignore_skip_ci
:,
save_on_errors
:)
unless
project
.
builds_enabled?
raise
ParameterValida
tionError
,
error
(
'Pipeline is disabled'
)
raise
InsufficientCondi
tionError
,
error
(
'Pipeline is disabled'
)
end
unless
allowed_to_trigger_pipeline?
(
triggering_user
)
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
raise
ParameterValida
tionError
,
error
(
'Insufficient permissions to create a new pipeline'
)
raise
InsufficientCondi
tionError
,
error
(
'Insufficient permissions to create a new pipeline'
)
end
end
unless
branch?
||
tag?
raise
ParameterValida
tionError
,
error
(
'Reference not found'
)
raise
InsufficientCondi
tionError
,
error
(
'Reference not found'
)
end
unless
commit
raise
ParameterValida
tionError
,
error
(
'Commit not found'
)
raise
InsufficientCondi
tionError
,
error
(
'Commit not found'
)
end
unless
pipeline
.
config_processor
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
raise
ParameterValida
tionError
,
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
raise
InsufficientCondi
tionError
,
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
end
if
!
ignore_skip_ci
&&
skip_ci?
pipeline
.
skip
if
save_on_errors
r
eturn
pipeline
r
aise
InsufficientConditionError
,
pipeline
end
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
...
...
spec/services/ci/pipeline_trigger_service_spec.rb
View file @
48389e99
...
...
@@ -40,15 +40,6 @@ describe Ci::PipelineTriggerService, services: true do
expect
(
result
[
:pipeline
].
variables
.
first
.
value
).
to
eq
(
variables
.
values
.
first
)
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
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