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
Boxiang Sun
gitlab-ce
Commits
c1918fb1
Commit
c1918fb1
authored
Jul 17, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a new `retry` CI/CD configuration keyword
parent
683fd52c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
4 deletions
+70
-4
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-1
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+7
-3
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+22
-0
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+39
-0
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
c1918fb1
...
@@ -83,7 +83,8 @@ module Ci
...
@@ -83,7 +83,8 @@ module Ci
before_script:
job
[
:before_script
],
before_script:
job
[
:before_script
],
script:
job
[
:script
],
script:
job
[
:script
],
after_script:
job
[
:after_script
],
after_script:
job
[
:after_script
],
environment:
job
[
:environment
]
environment:
job
[
:environment
],
retry:
job
[
:retry
]
}.
compact
}
}.
compact
}
end
end
...
...
lib/gitlab/ci/config/entry/job.rb
View file @
c1918fb1
...
@@ -11,7 +11,7 @@ module Gitlab
...
@@ -11,7 +11,7 @@ module Gitlab
ALLOWED_KEYS
=
%i[tags script only except type image services allow_failure
ALLOWED_KEYS
=
%i[tags script only except type image services allow_failure
type stage when artifacts cache dependencies before_script
type stage when artifacts cache dependencies before_script
after_script variables environment coverage]
.
freeze
after_script variables environment coverage
retry
]
.
freeze
validations
do
validations
do
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
allowed_keys:
ALLOWED_KEYS
...
@@ -23,6 +23,9 @@ module Gitlab
...
@@ -23,6 +23,9 @@ module Gitlab
with_options
allow_nil:
true
do
with_options
allow_nil:
true
do
validates
:tags
,
array_of_strings:
true
validates
:tags
,
array_of_strings:
true
validates
:allow_failure
,
boolean:
true
validates
:allow_failure
,
boolean:
true
validates
:retry
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
,
less_than:
10
}
validates
:when
,
validates
:when
,
inclusion:
{
in:
%w[on_success on_failure always manual]
,
inclusion:
{
in:
%w[on_success on_failure always manual]
,
message:
'should be on_success, on_failure, '
\
message:
'should be on_success, on_failure, '
\
...
@@ -76,9 +79,9 @@ module Gitlab
...
@@ -76,9 +79,9 @@ module Gitlab
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:artifacts
,
:commands
,
:environment
,
:coverage
:artifacts
,
:commands
,
:environment
,
:coverage
,
:retry
attributes
:script
,
:tags
,
:allow_failure
,
:when
,
:dependencies
attributes
:script
,
:tags
,
:allow_failure
,
:when
,
:dependencies
,
:retry
def
compose!
(
deps
=
nil
)
def
compose!
(
deps
=
nil
)
super
do
super
do
...
@@ -142,6 +145,7 @@ module Gitlab
...
@@ -142,6 +145,7 @@ module Gitlab
environment:
environment_defined?
?
environment_value
:
nil
,
environment:
environment_defined?
?
environment_value
:
nil
,
environment_name:
environment_defined?
?
environment_value
[
:name
]
:
nil
,
environment_name:
environment_defined?
?
environment_value
[
:name
]
:
nil
,
coverage:
coverage_defined?
?
coverage_value
:
nil
,
coverage:
coverage_defined?
?
coverage_value
:
nil
,
retry:
retry_defined?
?
retry_value
.
to_i
:
nil
,
artifacts:
artifacts_value
,
artifacts:
artifacts_value
,
after_script:
after_script_value
,
after_script:
after_script_value
,
ignore:
ignored?
}
ignore:
ignored?
}
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
c1918fb1
...
@@ -32,6 +32,28 @@ module Ci
...
@@ -32,6 +32,28 @@ module Ci
end
end
end
end
describe
'retry entry'
do
context
'when retry count is specified'
do
let
(
:config
)
do
YAML
.
dump
(
rspec:
{
script:
'rspec'
,
retry:
3
})
end
it
'includes retry count in build options attribute'
do
expect
(
subject
[
:options
]).
to
include
(
retry:
3
)
end
end
context
'when retry count is not specified'
do
let
(
:config
)
do
YAML
.
dump
(
rspec:
{
script:
'rspec'
})
end
it
'does not persist retry count in the database'
do
expect
(
subject
[
:options
]).
not_to
have_key
(
:retry
)
end
end
end
describe
'allow failure entry'
do
describe
'allow failure entry'
do
context
'when job is a manual action'
do
context
'when job is a manual action'
do
context
'when allow_failure is defined'
do
context
'when allow_failure is defined'
do
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
View file @
c1918fb1
...
@@ -80,6 +80,45 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -80,6 +80,45 @@ describe Gitlab::Ci::Config::Entry::Job do
expect
(
entry
.
errors
).
to
include
"job script can't be blank"
expect
(
entry
.
errors
).
to
include
"job script can't be blank"
end
end
end
end
context
'when retry value is not correct'
do
context
'when it is not a numeric value'
do
let
(
:config
)
{
{
retry:
true
}
}
it
'returns error about invalid type'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job retry is not a number'
end
end
context
'when it is lower than zero'
do
let
(
:config
)
{
{
retry:
-
1
}
}
it
'returns error about value too low'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
)
.
to
include
'job retry must be greater than or equal to 0'
end
end
context
'when it is not an integer'
do
let
(
:config
)
{
{
retry:
1.5
}
}
it
'returns error about wrong value'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job retry must be an integer'
end
end
context
'when the value is too high'
do
let
(
:config
)
{
{
retry:
10
}
}
it
'returns error about value too high'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'job retry must be less than 10'
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