Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
57a4ee88
Commit
57a4ee88
authored
Oct 01, 2018
by
Pierre Tardy
Committed by
Kamil Trzciński
Oct 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add variables on pipeline webhook
parent
34d24c1f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
17 deletions
+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
No files found.
app/models/ci/pipeline_variable.rb
View file @
57a4ee88
...
@@ -10,5 +10,9 @@ module Ci
...
@@ -10,5 +10,9 @@ module Ci
alias_attribute
:secret_value
,
:value
alias_attribute
:secret_value
,
:value
validates
:key
,
uniqueness:
{
scope: :pipeline_id
}
validates
:key
,
uniqueness:
{
scope: :pipeline_id
}
def
hook_attrs
{
key:
key
,
value:
value
}
end
end
end
end
end
changelogs/unreleased/pipeline-event-variables.yml
0 → 100644
View file @
57a4ee88
---
title
:
pipeline webhook event now contain pipeline variables
merge_request
:
18171
author
:
Pierre Tardy
type
:
added
doc/user/project/integrations/webhooks.md
View file @
57a4ee88
...
@@ -943,7 +943,13 @@ X-Gitlab-Event: Pipeline Hook
...
@@ -943,7 +943,13 @@ X-Gitlab-Event: Pipeline Hook
],
],
"created_at"
:
"2016-08-12 15:23:28 UTC"
,
"created_at"
:
"2016-08-12 15:23:28 UTC"
,
"finished_at"
:
"2016-08-12 15:26:29 UTC"
,
"finished_at"
:
"2016-08-12 15:26:29 UTC"
,
"duration"
:
63
"duration"
:
63
,
"variables"
:
[
{
"key"
:
"NESTOR_PROD_ENVIRONMENT"
,
"value"
:
"us-west-1"
}
]
},
},
"user"
:{
"user"
:{
"name"
:
"Administrator"
,
"name"
:
"Administrator"
,
...
...
lib/gitlab/data_builder/pipeline.rb
View file @
57a4ee88
...
@@ -26,7 +26,8 @@ module Gitlab
...
@@ -26,7 +26,8 @@ module Gitlab
stages:
pipeline
.
stages_names
,
stages:
pipeline
.
stages_names
,
created_at:
pipeline
.
created_at
,
created_at:
pipeline
.
created_at
,
finished_at:
pipeline
.
finished_at
,
finished_at:
pipeline
.
finished_at
,
duration:
pipeline
.
duration
duration:
pipeline
.
duration
,
variables:
pipeline
.
variables
.
map
(
&
:hook_attrs
)
}
}
end
end
...
...
spec/lib/gitlab/data_builder/pipeline_spec.rb
View file @
57a4ee88
...
@@ -6,10 +6,10 @@ describe Gitlab::DataBuilder::Pipeline do
...
@@ -6,10 +6,10 @@ describe Gitlab::DataBuilder::Pipeline do
let
(
:pipeline
)
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
create
(
:ci_pipeline
,
project:
project
,
project:
project
,
status:
'success'
,
status:
'success'
,
sha:
project
.
commit
.
sha
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
ref:
project
.
default_branch
)
end
end
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
...
@@ -20,18 +20,35 @@ describe Gitlab::DataBuilder::Pipeline do
...
@@ -20,18 +20,35 @@ describe Gitlab::DataBuilder::Pipeline do
let
(
:build_data
)
{
data
[
:builds
].
first
}
let
(
:build_data
)
{
data
[
:builds
].
first
}
let
(
:project_data
)
{
data
[
:project
]
}
let
(
:project_data
)
{
data
[
:project
]
}
it
{
expect
(
attributes
).
to
be_a
(
Hash
)
}
it
'has correct attributes'
do
it
{
expect
(
attributes
[
:ref
]).
to
eq
(
pipeline
.
ref
)
}
expect
(
attributes
).
to
be_a
(
Hash
)
it
{
expect
(
attributes
[
:sha
]).
to
eq
(
pipeline
.
sha
)
}
expect
(
attributes
[
:ref
]).
to
eq
(
pipeline
.
ref
)
it
{
expect
(
attributes
[
:tag
]).
to
eq
(
pipeline
.
tag
)
}
expect
(
attributes
[
:sha
]).
to
eq
(
pipeline
.
sha
)
it
{
expect
(
attributes
[
:id
]).
to
eq
(
pipeline
.
id
)
}
expect
(
attributes
[
:tag
]).
to
eq
(
pipeline
.
tag
)
it
{
expect
(
attributes
[
:status
]).
to
eq
(
pipeline
.
status
)
}
expect
(
attributes
[
:id
]).
to
eq
(
pipeline
.
id
)
it
{
expect
(
attributes
[
:detailed_status
]).
to
eq
(
'passed'
)
}
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
)
}
context
'pipeline without variables'
do
it
{
expect
(
build_data
[
:id
]).
to
eq
(
build
.
id
)
}
it
'has empty variables hash'
do
it
{
expect
(
build_data
[
:status
]).
to
eq
(
build
.
status
)
}
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
end
end
spec/models/ci/pipeline_variable_spec.rb
View file @
57a4ee88
...
@@ -5,4 +5,13 @@ describe Ci::PipelineVariable do
...
@@ -5,4 +5,13 @@ describe Ci::PipelineVariable do
it
{
is_expected
.
to
include_module
(
HasVariable
)
}
it
{
is_expected
.
to
include_module
(
HasVariable
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
).
scoped_to
(
:pipeline_id
)
}
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment