Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
57a4ee88
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,发现更多精彩内容 >>
提交
57a4ee88
编写于
10月 01, 2018
作者:
P
Pierre Tardy
提交者:
Kamil Trzciński
10月 01, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add variables on pipeline webhook
上级
34d24c1f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
59 addition
and
17 deletion
+59
-17
app/models/ci/pipeline_variable.rb
app/models/ci/pipeline_variable.rb
+4
-0
changelogs/unreleased/pipeline-event-variables.yml
changelogs/unreleased/pipeline-event-variables.yml
+5
-0
doc/user/project/integrations/webhooks.md
doc/user/project/integrations/webhooks.md
+7
-1
lib/gitlab/data_builder/pipeline.rb
lib/gitlab/data_builder/pipeline.rb
+2
-1
spec/lib/gitlab/data_builder/pipeline_spec.rb
spec/lib/gitlab/data_builder/pipeline_spec.rb
+32
-15
spec/models/ci/pipeline_variable_spec.rb
spec/models/ci/pipeline_variable_spec.rb
+9
-0
未找到文件。
app/models/ci/pipeline_variable.rb
浏览文件 @
57a4ee88
...
...
@@ -10,5 +10,9 @@ module Ci
alias_attribute
:secret_value
,
:value
validates
:key
,
uniqueness:
{
scope: :pipeline_id
}
def
hook_attrs
{
key:
key
,
value:
value
}
end
end
end
changelogs/unreleased/pipeline-event-variables.yml
0 → 100644
浏览文件 @
57a4ee88
---
title
:
pipeline webhook event now contain pipeline variables
merge_request
:
18171
author
:
Pierre Tardy
type
:
added
doc/user/project/integrations/webhooks.md
浏览文件 @
57a4ee88
...
...
@@ -943,7 +943,13 @@ X-Gitlab-Event: Pipeline Hook
],
"created_at"
:
"2016-08-12 15:23:28 UTC"
,
"finished_at"
:
"2016-08-12 15:26:29 UTC"
,
"duration"
:
63
"duration"
:
63
,
"variables"
:
[
{
"key"
:
"NESTOR_PROD_ENVIRONMENT"
,
"value"
:
"us-west-1"
}
]
},
"user"
:{
"name"
:
"Administrator"
,
...
...
lib/gitlab/data_builder/pipeline.rb
浏览文件 @
57a4ee88
...
...
@@ -26,7 +26,8 @@ module Gitlab
stages:
pipeline
.
stages_names
,
created_at:
pipeline
.
created_at
,
finished_at:
pipeline
.
finished_at
,
duration:
pipeline
.
duration
duration:
pipeline
.
duration
,
variables:
pipeline
.
variables
.
map
(
&
:hook_attrs
)
}
end
...
...
spec/lib/gitlab/data_builder/pipeline_spec.rb
浏览文件 @
57a4ee88
...
...
@@ -6,10 +6,10 @@ describe Gitlab::DataBuilder::Pipeline do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
status:
'success'
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
project:
project
,
status:
'success'
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
end
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
...
...
@@ -20,18 +20,35 @@ describe Gitlab::DataBuilder::Pipeline do
let
(
:build_data
)
{
data
[
:builds
].
first
}
let
(
:project_data
)
{
data
[
:project
]
}
it
{
expect
(
attributes
).
to
be_a
(
Hash
)
}
it
{
expect
(
attributes
[
:ref
]).
to
eq
(
pipeline
.
ref
)
}
it
{
expect
(
attributes
[
:sha
]).
to
eq
(
pipeline
.
sha
)
}
it
{
expect
(
attributes
[
:tag
]).
to
eq
(
pipeline
.
tag
)
}
it
{
expect
(
attributes
[
:id
]).
to
eq
(
pipeline
.
id
)
}
it
{
expect
(
attributes
[
:status
]).
to
eq
(
pipeline
.
status
)
}
it
{
expect
(
attributes
[
:detailed_status
]).
to
eq
(
'passed'
)
}
it
'has correct attributes'
do
expect
(
attributes
).
to
be_a
(
Hash
)
expect
(
attributes
[
:ref
]).
to
eq
(
pipeline
.
ref
)
expect
(
attributes
[
:sha
]).
to
eq
(
pipeline
.
sha
)
expect
(
attributes
[
:tag
]).
to
eq
(
pipeline
.
tag
)
expect
(
attributes
[
:id
]).
to
eq
(
pipeline
.
id
)
expect
(
attributes
[
:status
]).
to
eq
(
pipeline
.
status
)
expect
(
attributes
[
:detailed_status
]).
to
eq
(
'passed'
)
expect
(
build_data
).
to
be_a
(
Hash
)
expect
(
build_data
[
:id
]).
to
eq
(
build
.
id
)
expect
(
build_data
[
:status
]).
to
eq
(
build
.
status
)
expect
(
project_data
).
to
eq
(
project
.
hook_attrs
(
backward:
false
))
end
it
{
expect
(
build_data
).
to
be_a
(
Hash
)
}
it
{
expect
(
build_data
[
:id
]).
to
eq
(
build
.
id
)
}
it
{
expect
(
build_data
[
:status
]).
to
eq
(
build
.
status
)
}
context
'pipeline without variables'
do
it
'has empty variables hash'
do
expect
(
attributes
[
:variables
]).
to
be_a
(
Array
)
expect
(
attributes
[
:variables
]).
to
be_empty
()
end
end
it
{
expect
(
project_data
).
to
eq
(
project
.
hook_attrs
(
backward:
false
))
}
context
'pipeline with variables'
do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:data
)
{
described_class
.
build
(
pipeline
)
}
let
(
:attributes
)
{
data
[
:object_attributes
]
}
let!
(
:pipeline_variable
)
{
create
(
:ci_pipeline_variable
,
pipeline:
pipeline
,
key:
'TRIGGER_KEY_1'
,
value:
'TRIGGER_VALUE_1'
)
}
it
{
expect
(
attributes
[
:variables
]).
to
be_a
(
Array
)
}
it
{
expect
(
attributes
[
:variables
]).
to
contain_exactly
({
key:
'TRIGGER_KEY_1'
,
value:
'TRIGGER_VALUE_1'
})
}
end
end
end
spec/models/ci/pipeline_variable_spec.rb
浏览文件 @
57a4ee88
...
...
@@ -5,4 +5,13 @@ describe Ci::PipelineVariable do
it
{
is_expected
.
to
include_module
(
HasVariable
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
).
scoped_to
(
:pipeline_id
)
}
describe
'#hook_attrs'
do
let
(
:variable
)
{
create
(
:ci_pipeline_variable
,
key:
'foo'
,
value:
'bar'
)
}
subject
{
variable
.
hook_attrs
}
it
{
is_expected
.
to
be_a
(
Hash
)
}
it
{
is_expected
.
to
eq
({
key:
'foo'
,
value:
'bar'
})
}
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录