Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c1918fb1
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c1918fb1
编写于
7月 17, 2017
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a new `retry` CI/CD configuration keyword
上级
683fd52c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
4 deletion
+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
未找到文件。
lib/ci/gitlab_ci_yaml_processor.rb
浏览文件 @
c1918fb1
...
...
@@ -83,7 +83,8 @@ module Ci
before_script:
job
[
:before_script
],
script:
job
[
:script
],
after_script:
job
[
:after_script
],
environment:
job
[
:environment
]
environment:
job
[
:environment
],
retry:
job
[
:retry
]
}.
compact
}
end
...
...
lib/gitlab/ci/config/entry/job.rb
浏览文件 @
c1918fb1
...
...
@@ -11,7 +11,7 @@ module Gitlab
ALLOWED_KEYS
=
%i[tags script only except type image services allow_failure
type stage when artifacts cache dependencies before_script
after_script variables environment coverage]
.
freeze
after_script variables environment coverage
retry
]
.
freeze
validations
do
validates
:config
,
allowed_keys:
ALLOWED_KEYS
...
...
@@ -23,6 +23,9 @@ module Gitlab
with_options
allow_nil:
true
do
validates
:tags
,
array_of_strings:
true
validates
:allow_failure
,
boolean:
true
validates
:retry
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
,
less_than:
10
}
validates
:when
,
inclusion:
{
in:
%w[on_success on_failure always manual]
,
message:
'should be on_success, on_failure, '
\
...
...
@@ -76,9 +79,9 @@ module Gitlab
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
: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
)
super
do
...
...
@@ -142,6 +145,7 @@ module Gitlab
environment:
environment_defined?
?
environment_value
:
nil
,
environment_name:
environment_defined?
?
environment_value
[
:name
]
:
nil
,
coverage:
coverage_defined?
?
coverage_value
:
nil
,
retry:
retry_defined?
?
retry_value
.
to_i
:
nil
,
artifacts:
artifacts_value
,
after_script:
after_script_value
,
ignore:
ignored?
}
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
浏览文件 @
c1918fb1
...
...
@@ -32,6 +32,28 @@ module Ci
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
context
'when job is a manual action'
do
context
'when allow_failure is defined'
do
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
浏览文件 @
c1918fb1
...
...
@@ -80,6 +80,45 @@ describe Gitlab::Ci::Config::Entry::Job do
expect
(
entry
.
errors
).
to
include
"job script can't be blank"
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录