Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8db63b26
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,发现更多精彩内容 >>
提交
8db63b26
编写于
6月 01, 2017
作者:
F
Filip Krakowski
提交者:
Shinya Maeda
6月 08, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use pipeline.source to determine what triggered a pipeline
上级
fe9b78d6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
21 deletion
+21
-21
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+1
-1
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+16
-16
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+4
-4
未找到文件。
doc/ci/yaml/README.md
浏览文件 @
8db63b26
...
...
@@ -411,7 +411,7 @@ job:
```
In this example,
`job`
will run only for refs that are tagged, or if a build is
explicitly requested via an API trigger or a
Pipeline Schedule
.
explicitly requested via an API trigger or a
[
Pipeline Schedule
](
../../user/project/pipelines/schedules.md
)
.
```
yaml
job
:
...
...
lib/ci/gitlab_ci_yaml_processor.rb
浏览文件 @
8db63b26
...
...
@@ -20,26 +20,26 @@ module Ci
raise
ValidationError
,
e
.
message
end
def
jobs_for_ref
(
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
def
jobs_for_ref
(
ref
,
tag
=
false
,
sourc
e
=
nil
)
@jobs
.
select
do
|
_
,
job
|
process?
(
job
[
:only
],
job
[
:except
],
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
process?
(
job
[
:only
],
job
[
:except
],
ref
,
tag
,
sourc
e
)
end
end
def
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
).
select
do
|
_
,
job
|
def
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
sourc
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
sourc
e
).
select
do
|
_
,
job
|
job
[
:stage
]
==
stage
end
end
def
builds_for_ref
(
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
).
map
do
|
name
,
_
|
def
builds_for_ref
(
ref
,
tag
=
false
,
sourc
e
=
nil
)
jobs_for_ref
(
ref
,
tag
,
sourc
e
).
map
do
|
name
,
_
|
build_attributes
(
name
)
end
end
def
builds_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
trigger_request
=
nil
,
pipeline_schedul
e
=
nil
)
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
).
map
do
|
name
,
_
|
def
builds_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
sourc
e
=
nil
)
jobs_for_stage_and_ref
(
stage
,
ref
,
tag
,
sourc
e
).
map
do
|
name
,
_
|
build_attributes
(
name
)
end
end
...
...
@@ -193,31 +193,31 @@ module Ci
end
end
def
process?
(
only_params
,
except_params
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
def
process?
(
only_params
,
except_params
,
ref
,
tag
,
sourc
e
)
if
only_params
.
present?
return
false
unless
matching?
(
only_params
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
return
false
unless
matching?
(
only_params
,
ref
,
tag
,
sourc
e
)
end
if
except_params
.
present?
return
false
if
matching?
(
except_params
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
return
false
if
matching?
(
except_params
,
ref
,
tag
,
sourc
e
)
end
true
end
def
matching?
(
patterns
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
def
matching?
(
patterns
,
ref
,
tag
,
sourc
e
)
patterns
.
any?
do
|
pattern
|
match_ref?
(
pattern
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
match_ref?
(
pattern
,
ref
,
tag
,
sourc
e
)
end
end
def
match_ref?
(
pattern
,
ref
,
tag
,
trigger_request
,
pipeline_schedul
e
)
def
match_ref?
(
pattern
,
ref
,
tag
,
sourc
e
)
pattern
,
path
=
pattern
.
split
(
'@'
,
2
)
return
false
if
path
&&
path
!=
self
.
path
return
true
if
tag
&&
pattern
==
'tags'
return
true
if
!
tag
&&
pattern
==
'branches'
return
true
if
trigger_request
.
present?
&&
pattern
==
'triggers'
return
true
if
pipeline_schedule
.
present?
&&
pattern
==
'schedules'
return
true
if
source
==
'trigger'
&&
pattern
==
'triggers'
return
true
if
source
==
'schedule'
&&
pattern
==
'schedules'
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
Regexp
.
new
(
pattern
[
1
...-
1
])
=~
ref
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
浏览文件 @
8db63b26
...
...
@@ -227,7 +227,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
true
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'trigger'
).
size
).
to
eq
(
1
)
end
it
"returns builds if only has a schedules keyword specified and a schedule is provided"
do
...
...
@@ -238,7 +238,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
false
,
true
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'schedule'
).
size
).
to
eq
(
1
)
end
it
"does not return builds if only has a triggers keyword specified and no trigger is provided"
do
...
...
@@ -405,7 +405,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
true
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'trigger'
).
size
).
to
eq
(
0
)
end
it
"does not return builds if except has a schedules keyword specified and a schedule is provided"
do
...
...
@@ -416,7 +416,7 @@ module Ci
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
false
,
true
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
'schedule'
).
size
).
to
eq
(
0
)
end
it
"returns builds if except has a triggers keyword specified and no trigger is provided"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录