Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c03da1ca
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 搜索 >>
提交
c03da1ca
编写于
11月 02, 2015
作者:
K
Kamil Trzcinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extend yml syntax for only and except to support specifying repository path
上级
329e067f
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
273 addition
and
111 deletion
+273
-111
CHANGELOG
CHANGELOG
+1
-0
app/models/ci/commit.rb
app/models/ci/commit.rb
+1
-1
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+13
-1
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+34
-30
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+224
-79
未找到文件。
CHANGELOG
浏览文件 @
c03da1ca
...
...
@@ -13,6 +13,7 @@ v 8.2.0 (unreleased)
- Fix: Inability to reply to code comments in the MR view, if the MR comes from a fork
- Use git follow flag for commits page when retrieve history for file or directory
- Show merge request CI status on merge requests index page
- Extend yml syntax for only and except to support specifying repository path
- Fix: 500 error returned if destroy request without HTTP referer (Kazuki Shimizu)
- Remove deprecated CI events from project settings page
- Use issue editor as cross reference comment author when issue is edited with a new mention.
...
...
app/models/ci/commit.rb
浏览文件 @
c03da1ca
...
...
@@ -187,7 +187,7 @@ module Ci
end
def
config_processor
@config_processor
||=
Ci
::
GitlabCiYamlProcessor
.
new
(
ci_yaml_file
)
@config_processor
||=
Ci
::
GitlabCiYamlProcessor
.
new
(
ci_yaml_file
,
gl_project
.
path_with_namespace
)
rescue
Ci
::
GitlabCiYamlProcessor
::
ValidationError
=>
e
save_yaml_error
(
e
.
message
)
nil
...
...
doc/ci/yaml/README.md
浏览文件 @
c03da1ca
...
...
@@ -169,7 +169,7 @@ This are two parameters that allow for setting a refs policy to limit when jobs
There are a few rules that apply to usage of refs policy:
1.
`only`
and
`except`
are
exclusive. If both
`only`
and
`except`
are defined in job specification only
`only`
is taken into account
.
1.
`only`
and
`except`
are
inclusive. If both
`only`
and
`except`
are defined in job specification the ref is filtered by
`only`
and
`except`
.
1.
`only`
and
`except`
allow for using the regexp expressions.
1.
`only`
and
`except`
allow for using special keywords:
`branches`
and
`tags`
.
These names can be used for example to exclude all tags and all branches.
...
...
@@ -182,6 +182,18 @@ job:
-
branches
# use special keyword
```
1.
`only`
and
`except`
allow for specify repository path to filter jobs for forks.
The repository path can be used to have jobs executed only for parent repository.
```
yaml
job
:
only
:
-
branches@gitlab-org/gitlab-ce
except
:
-
master@gitlab-org/gitlab-ce
```
The above will run
`job`
for all branches, except master on
`gitlab-org/gitlab-ce`
repository only.
### tags
`tags`
is used to select specific runners from the list of all runners that are allowed to run this project.
...
...
lib/ci/gitlab_ci_yaml_processor.rb
浏览文件 @
c03da1ca
...
...
@@ -7,10 +7,11 @@ module Ci
ALLOWED_YAML_KEYS
=
[
:before_script
,
:image
,
:services
,
:types
,
:stages
,
:variables
]
ALLOWED_JOB_KEYS
=
[
:tags
,
:script
,
:only
,
:except
,
:type
,
:image
,
:services
,
:allow_failure
,
:type
,
:stage
,
:when
]
attr_reader
:before_script
,
:image
,
:services
,
:variables
attr_reader
:before_script
,
:image
,
:services
,
:variables
,
:path
def
initialize
(
config
)
def
initialize
(
config
,
path
=
nil
)
@config
=
YAML
.
load
(
config
)
@path
=
path
unless
@config
.
is_a?
Hash
raise
ValidationError
,
"YAML should be a hash"
...
...
@@ -63,26 +64,6 @@ module Ci
end
end
def
process?
(
only_params
,
except_params
,
ref
,
tag
)
return
true
if
only_params
.
nil?
&&
except_params
.
nil?
if
only_params
return
true
if
tag
&&
only_params
.
include?
(
"tags"
)
return
true
if
!
tag
&&
only_params
.
include?
(
"branches"
)
only_params
.
find
do
|
pattern
|
match_ref?
(
pattern
,
ref
)
end
else
return
false
if
tag
&&
except_params
.
include?
(
"tags"
)
return
false
if
!
tag
&&
except_params
.
include?
(
"branches"
)
except_params
.
each
do
|
pattern
|
return
false
if
match_ref?
(
pattern
,
ref
)
end
end
end
def
build_job
(
name
,
job
)
{
stage_idx:
stages
.
index
(
job
[
:stage
]),
...
...
@@ -101,14 +82,6 @@ module Ci
}
end
def
match_ref?
(
pattern
,
ref
)
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
Regexp
.
new
(
pattern
[
1
...-
1
])
=~
ref
else
pattern
==
ref
end
end
def
normalize_script
(
script
)
if
script
.
is_a?
Array
script
.
join
(
"
\n
"
)
...
...
@@ -208,5 +181,36 @@ module Ci
def
validate_string
(
value
)
value
.
is_a?
(
String
)
||
value
.
is_a?
(
Symbol
)
end
def
process?
(
only_params
,
except_params
,
ref
,
tag
)
if
only_params
.
present?
return
false
unless
matching?
(
only_params
,
ref
,
tag
)
end
if
except_params
.
present?
return
false
if
matching?
(
except_params
,
ref
,
tag
)
end
true
end
def
matching?
(
patterns
,
ref
,
tag
)
patterns
.
any?
do
|
pattern
|
match_ref?
(
pattern
,
ref
,
tag
)
end
end
def
match_ref?
(
pattern
,
ref
,
tag
)
pattern
,
path
=
pattern
.
split
(
'@'
,
2
)
return
false
if
path
&&
path
!=
self
.
path
return
true
if
tag
&&
pattern
==
'tags'
return
true
if
!
tag
&&
pattern
==
'branches'
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
Regexp
.
new
(
pattern
[
1
...-
1
])
=~
ref
else
pattern
==
ref
end
end
end
end
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
浏览文件 @
c03da1ca
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录