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
Léo-Paul Géneau
gitlab-ce
Commits
1501940e
Commit
1501940e
authored
Jun 10, 2016
by
Kamil Trzcinski
Committed by
Phil Hughes
Jun 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate artifacts:expire_in in yaml processor
parent
ee7c5539
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+10
-0
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+22
-2
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
1501940e
...
...
@@ -282,6 +282,10 @@ module Ci
if
job
[
:artifacts
][
:when
]
&&
!
job
[
:artifacts
][
:when
].
in?
(
%w(on_success on_failure always)
)
raise
ValidationError
,
"
#{
name
}
job: artifacts:when parameter should be on_success, on_failure or always"
end
if
job
[
:artifacts
][
:expire_in
]
&&
!
validate_duration
(
job
[
:artifacts
][
:expire_in
])
raise
ValidationError
,
"
#{
name
}
job: artifacts:expire_in parameter should be a duration"
end
end
def
validate_job_dependencies!
(
name
,
job
)
...
...
@@ -300,6 +304,12 @@ module Ci
end
end
def
validate_duration
(
value
)
value
.
is_a?
(
String
)
&&
ChronicDuration
.
parse
(
value
)
rescue
ChronicDuration
::
DurationParseError
false
end
def
validate_array_of_strings
(
values
)
values
.
is_a?
(
Array
)
&&
values
.
all?
{
|
value
|
validate_string
(
value
)
}
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
1501940e
...
...
@@ -572,7 +572,12 @@ module Ci
services:
[
"mysql"
],
before_script:
[
"pwd"
],
rspec:
{
artifacts:
{
paths:
[
"logs/"
,
"binaries/"
],
untracked:
true
,
name:
"custom_name"
},
artifacts:
{
paths:
[
"logs/"
,
"binaries/"
],
untracked:
true
,
name:
"custom_name"
,
expire_in:
"7d"
},
script:
"rspec"
}
})
...
...
@@ -594,7 +599,8 @@ module Ci
artifacts:
{
name:
"custom_name"
,
paths:
[
"logs/"
,
"binaries/"
],
untracked:
true
untracked:
true
,
expire_in:
"7d"
}
},
when:
"on_success"
,
...
...
@@ -990,6 +996,20 @@ EOT
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: artifacts:when parameter should be on_success, on_failure or always"
)
end
it
"returns errors if job artifacts:expire_in is not an a string"
do
config
=
YAML
.
dump
({
types:
[
"build"
,
"test"
],
rspec:
{
script:
"test"
,
artifacts:
{
expire_in:
1
}
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: artifacts:expire_in parameter should be a duration"
)
end
it
"returns errors if job artifacts:expire_in is not an a valid duration"
do
config
=
YAML
.
dump
({
types:
[
"build"
,
"test"
],
rspec:
{
script:
"test"
,
artifacts:
{
expire_in:
"7 elephants"
}
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"rspec job: artifacts:expire_in parameter should be a duration"
)
end
it
"returns errors if job artifacts:untracked is not an array of strings"
do
config
=
YAML
.
dump
({
types:
[
"build"
,
"test"
],
rspec:
{
script:
"test"
,
artifacts:
{
untracked:
"string"
}
}
})
expect
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