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
Tatuya Kamada
gitlab-ce
Commits
2b907f61
Commit
2b907f61
authored
Nov 18, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commits without .gitlab-ci.yml are marked as skipped
- Save detailed error when YAML syntax
parent
a42d469a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
app/models/ci/commit.rb
app/models/ci/commit.rb
+4
-1
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+5
-1
spec/services/ci/create_commit_service_spec.rb
spec/services/ci/create_commit_service_spec.rb
+19
-1
No files found.
app/models/ci/commit.rb
View file @
2b907f61
...
@@ -188,12 +188,15 @@ module Ci
...
@@ -188,12 +188,15 @@ module Ci
end
end
def
config_processor
def
config_processor
return
nil
unless
ci_yaml_file
@config_processor
||=
Ci
::
GitlabCiYamlProcessor
.
new
(
ci_yaml_file
,
gl_project
.
path_with_namespace
)
@config_processor
||=
Ci
::
GitlabCiYamlProcessor
.
new
(
ci_yaml_file
,
gl_project
.
path_with_namespace
)
rescue
Ci
::
GitlabCiYamlProcessor
::
ValidationError
=>
e
rescue
Ci
::
GitlabCiYamlProcessor
::
ValidationError
=>
e
save_yaml_error
(
e
.
message
)
save_yaml_error
(
e
.
message
)
nil
nil
rescue
Psych
::
SyntaxError
=>
e
save_yaml_error
(
e
.
message
)
nil
rescue
Exception
=>
e
rescue
Exception
=>
e
logger
.
error
e
.
message
+
"
\n
"
+
e
.
backtrace
.
join
(
"
\n
"
)
save_yaml_error
(
"Undefined yaml error"
)
save_yaml_error
(
"Undefined yaml error"
)
nil
nil
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
2b907f61
...
@@ -425,8 +425,12 @@ module Ci
...
@@ -425,8 +425,12 @@ module Ci
end
end
describe
"Error handling"
do
describe
"Error handling"
do
it
"fails to parse YAML"
do
expect
{
GitlabCiYamlProcessor
.
new
(
"invalid: yaml: test"
)}.
to
raise_error
(
Psych
::
SyntaxError
)
end
it
"indicates that object is invalid"
do
it
"indicates that object is invalid"
do
expect
{
GitlabCiYamlProcessor
.
new
(
"invalid_yaml
\n
!ccdvlf%612334@@@@
"
)}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
)
expect
{
GitlabCiYamlProcessor
.
new
(
"invalid_yaml"
)}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
)
end
end
it
"returns errors if tags parameter is invalid"
do
it
"returns errors if tags parameter is invalid"
do
...
...
spec/services/ci/create_commit_service_spec.rb
View file @
2b907f61
...
@@ -100,7 +100,7 @@ module Ci
...
@@ -100,7 +100,7 @@ module Ci
end
end
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
stub_ci_commit_yaml_file
(
'invalid: file'
)
stub_ci_commit_yaml_file
(
'invalid: file
: fiile
'
)
commits
=
[{
message:
message
}]
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
...
@@ -110,6 +110,24 @@ module Ci
...
@@ -110,6 +110,24 @@ module Ci
)
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
yaml_errors
).
to
be_nil
end
end
describe
:config_processor
do
it
"skips builds creation if yaml is invalid"
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
"message"
}
stub_ci_commit_yaml_file
(
'invalid: file: file'
)
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
yaml_errors
).
to_not
be_nil
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