Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8dd27b47
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
8dd27b47
编写于
4月 21, 2016
作者:
T
Tomasz Maczukin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add posibility to define a hidden job without 'script' in .gitlab-ci.yml
上级
80893cad
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
53 deletion
+117
-53
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+7
-4
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+110
-49
未找到文件。
lib/ci/gitlab_ci_yaml_processor.rb
浏览文件 @
8dd27b47
...
...
@@ -63,9 +63,8 @@ module Ci
@cache
=
@config
[
:cache
]
@config
.
except!
(
*
ALLOWED_YAML_KEYS
)
# anything that doesn't have script is considered as unknown
@config
.
each
do
|
name
,
param
|
raise
ValidationError
,
"Unknown parameter:
#{
name
}
"
unless
param
.
is_a?
(
Hash
)
&&
param
.
has_key?
(
:script
)
raise
ValidationError
,
"Unknown parameter:
#{
name
}
"
unless
is_a_job?
(
name
,
param
)
end
unless
@config
.
values
.
any?
{
|
job
|
job
.
is_a?
(
Hash
)}
...
...
@@ -80,6 +79,12 @@ module Ci
end
end
def
is_a_job?
(
name
,
value
)
return
true
if
value
.
is_a?
(
Hash
)
&&
value
.
has_key?
(
:script
)
return
true
if
name
.
to_s
.
start_with?
(
'.'
)
false
end
def
build_job
(
name
,
job
)
{
stage_idx:
stages
.
index
(
job
[
:stage
]),
...
...
@@ -112,8 +117,6 @@ module Ci
true
end
private
def
validate_global!
unless
validate_array_of_strings
(
@before_script
)
raise
ValidationError
,
"before_script should be an array of strings"
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
浏览文件 @
8dd27b47
...
...
@@ -648,70 +648,131 @@ module Ci
end
describe
"Hidden jobs"
do
let
(
:config
)
do
YAML
.
dump
({
'.hidden_job'
=>
{
script:
'test'
},
'normal_job'
=>
{
script:
'test'
}
})
let
(
:config_processor
)
{
GitlabCiYamlProcessor
.
new
(
config
)
}
subject
{
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
)
}
shared_examples
'hidden_job_handling'
do
it
"doesn't create jobs that starts with dot"
do
expect
(
subject
.
size
).
to
eq
(
1
)
expect
(
subject
.
first
).
to
eq
({
except:
nil
,
stage:
"test"
,
stage_idx:
1
,
name: :normal_job
,
only:
nil
,
commands:
"test"
,
tag_list:
[],
options:
{},
when:
"on_success"
,
allow_failure:
false
})
end
end
let
(
:config_processor
)
{
GitlabCiYamlProcessor
.
new
(
config
)
}
context
'When hidden job have a script definition'
do
let
(
:config
)
do
YAML
.
dump
({
'.hidden_job'
=>
{
image:
'ruby:2.1'
,
script:
'test'
},
'normal_job'
=>
{
script:
'test'
}
})
end
subject
{
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
)
}
it_behaves_like
'hidden_job_handling'
end
it
"doesn't create jobs that starts with dot"
do
expect
(
subject
.
size
).
to
eq
(
1
)
expect
(
subject
.
first
).
to
eq
({
except:
nil
,
stage:
"test"
,
stage_idx:
1
,
name: :normal_job
,
only:
nil
,
commands:
"test"
,
tag_list:
[],
options:
{},
when:
"on_success"
,
allow_failure:
false
})
context
"When hidden job doesn't have a script definition"
do
let
(
:config
)
do
YAML
.
dump
({
'.hidden_job'
=>
{
image:
'ruby:2.1'
},
'normal_job'
=>
{
script:
'test'
}
})
end
it_behaves_like
'hidden_job_handling'
end
end
describe
"YAML Alias/Anchor"
do
it
"is correctly supported for jobs"
do
config
=
<<
EOT
let
(
:config_processor
)
{
GitlabCiYamlProcessor
.
new
(
config
)
}
subject
{
config_processor
.
builds_for_stage_and_ref
(
"build"
,
"master"
)
}
shared_examples
'job_templates_handling'
do
it
"is correctly supported for jobs"
do
expect
(
subject
.
size
).
to
eq
(
2
)
expect
(
subject
.
first
).
to
eq
({
except:
nil
,
stage:
"build"
,
stage_idx:
0
,
name: :job1
,
only:
nil
,
commands:
"execute-script-for-job"
,
tag_list:
[],
options:
{},
when:
"on_success"
,
allow_failure:
false
})
expect
(
subject
.
second
).
to
eq
({
except:
nil
,
stage:
"build"
,
stage_idx:
0
,
name: :job2
,
only:
nil
,
commands:
"execute-script-for-job"
,
tag_list:
[],
options:
{},
when:
"on_success"
,
allow_failure:
false
})
end
end
context
'When template is a job'
do
let
(
:config
)
do
<<
EOT
job1: &JOBTMPL
stage: build
script: execute-script-for-job
job2: *JOBTMPL
EOT
end
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
)
it_behaves_like
'job_templates_handling'
end
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
2
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
({
except:
nil
,
stage:
"test"
,
stage_idx:
1
,
name: :job1
,
only:
nil
,
commands:
"execute-script-for-job"
,
tag_list:
[],
options:
{},
when:
"on_success"
,
allow_failure:
false
})
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
second
).
to
eq
({
except:
nil
,
stage:
"test"
,
stage_idx:
1
,
name: :job2
,
only:
nil
,
commands:
"execute-script-for-job"
,
tag_list:
[],
options:
{},
when:
"on_success"
,
allow_failure:
false
})
context
'When template is a hidden job'
do
let
(
:config
)
do
<<
EOT
.template: &JOBTMPL
stage: build
script: execute-script-for-job
job1: *JOBTMPL
job2: *JOBTMPL
EOT
end
it_behaves_like
'job_templates_handling'
end
context
"When job adds it's own keys to a template definition"
do
let
(
:config
)
do
<<
EOT
.template: &JOBTMPL
stage: build
job1:
<<: *JOBTMPL
script: execute-script-for-job
job2:
<<: *JOBTMPL
script: execute-script-for-job
EOT
end
it_behaves_like
'job_templates_handling'
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录