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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
eaa91cbe
Commit
eaa91cbe
authored
Jun 17, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error when CI job variables not specified
parent
faee4763
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
18 deletions
+40
-18
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+1
-1
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+39
-17
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
eaa91cbe
...
@@ -54,7 +54,7 @@ module Ci
...
@@ -54,7 +54,7 @@ module Ci
job
=
@jobs
[
name
.
to_sym
]
job
=
@jobs
[
name
.
to_sym
]
return
[]
unless
job
return
[]
unless
job
job
.
fetch
(
:variables
,
[])
job
[
:variables
]
||
[]
end
end
private
private
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
eaa91cbe
...
@@ -287,13 +287,13 @@ module Ci
...
@@ -287,13 +287,13 @@ module Ci
end
end
end
end
describe
"Scripts handling"
do
describe
"Scripts handling"
do
let
(
:config_data
)
{
YAML
.
dump
(
config
)
}
let
(
:config_data
)
{
YAML
.
dump
(
config
)
}
let
(
:config_processor
)
{
GitlabCiYamlProcessor
.
new
(
config_data
,
path
)
}
let
(
:config_processor
)
{
GitlabCiYamlProcessor
.
new
(
config_data
,
path
)
}
subject
{
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
}
subject
{
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
}
describe
"before_script"
do
describe
"before_script"
do
context
"in global context"
do
context
"in global context"
do
let
(
:config
)
do
let
(
:config
)
do
...
@@ -302,12 +302,12 @@ module Ci
...
@@ -302,12 +302,12 @@ module Ci
test:
{
script:
[
"script"
]
}
test:
{
script:
[
"script"
]
}
}
}
end
end
it
"return commands with scripts concencaced"
do
it
"return commands with scripts concencaced"
do
expect
(
subject
[
:commands
]).
to
eq
(
"global script
\n
script"
)
expect
(
subject
[
:commands
]).
to
eq
(
"global script
\n
script"
)
end
end
end
end
context
"overwritten in local context"
do
context
"overwritten in local context"
do
let
(
:config
)
do
let
(
:config
)
do
{
{
...
@@ -465,19 +465,41 @@ module Ci
...
@@ -465,19 +465,41 @@ module Ci
end
end
context
'when syntax is incorrect'
do
context
'when syntax is incorrect'
do
it
'raises error'
do
context
'when variables defined but invalid'
do
variables
=
[
:KEY1
,
'value1'
,
:KEY2
,
'value2'
]
it
'raises error'
do
variables
=
[
:KEY1
,
'value1'
,
:KEY2
,
'value2'
]
config
=
YAML
.
dump
(
{
before_script:
[
'pwd'
],
config
=
YAML
.
dump
(
rspec:
{
{
before_script:
[
'pwd'
],
variables:
variables
,
rspec:
{
script:
'rspec'
}
variables:
variables
,
})
script:
'rspec'
}
})
expect
{
GitlabCiYamlProcessor
.
new
(
config
,
path
)
}
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
/job: variables should be a map/
)
end
end
expect
{
GitlabCiYamlProcessor
.
new
(
config
,
path
)
}
context
'when variables key defined but value not specified'
do
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
it
'returns empty array'
do
/job: variables should be a map/
)
config
=
YAML
.
dump
(
{
before_script:
[
'pwd'
],
rspec:
{
variables:
nil
,
script:
'rspec'
}
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
##
# TODO, in next version of CI configuration processor this
# should be invalid configuration, see #18775 and #15060
#
expect
(
config_processor
.
job_variables
(
:rspec
))
.
to
be_an_instance_of
(
Array
).
and
be_empty
end
end
end
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