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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
5fbbcbca
Commit
5fbbcbca
authored
Sep 11, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
bf250b44
9ac48b4e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
0 deletions
+53
-0
changelogs/unreleased/add-source-and-merge_request-to-pipeline-webhook.yml
...ased/add-source-and-merge_request-to-pipeline-webhook.yml
+5
-0
doc/user/project/integrations/webhooks.md
doc/user/project/integrations/webhooks.md
+13
-0
lib/gitlab/data_builder/pipeline.rb
lib/gitlab/data_builder/pipeline.rb
+17
-0
spec/lib/gitlab/data_builder/pipeline_spec.rb
spec/lib/gitlab/data_builder/pipeline_spec.rb
+18
-0
No files found.
changelogs/unreleased/add-source-and-merge_request-to-pipeline-webhook.yml
0 → 100644
View file @
5fbbcbca
---
title
:
Add source and merge_request fields to pipeline event webhook
merge_request
:
32373
author
:
Bian Jiaping
type
:
added
doc/user/project/integrations/webhooks.md
View file @
5fbbcbca
...
...
@@ -1001,6 +1001,7 @@ X-Gitlab-Event: Pipeline Hook
"tag"
:
false
,
"sha"
:
"bcbb5ec396a2c0f828686f14fac9b80b780504f2"
,
"before_sha"
:
"bcbb5ec396a2c0f828686f14fac9b80b780504f2"
,
"source"
:
"merge_request_event"
,
"status"
:
"success"
,
"stages"
:[
"build"
,
...
...
@@ -1016,6 +1017,18 @@ X-Gitlab-Event: Pipeline Hook
"value"
:
"us-west-1"
}
]
},
"merge_request"
:
{
"id"
:
1
,
"iid"
:
1
,
"title"
:
"Test"
,
"source_branch"
:
"test"
,
"source_project_id"
:
1
,
"target_branch"
:
"master"
,
"target_project_id"
:
1
,
"state"
:
"opened"
,
"merge_status"
:
"can_be_merged"
,
"url"
:
"http://192.168.64.1:3005/gitlab-org/gitlab-test/merge_requests/1"
},
"user"
:{
"name"
:
"Administrator"
,
...
...
lib/gitlab/data_builder/pipeline.rb
View file @
5fbbcbca
...
...
@@ -9,6 +9,7 @@ module Gitlab
{
object_kind:
'pipeline'
,
object_attributes:
hook_attrs
(
pipeline
),
merge_request:
pipeline
.
merge_request
&&
merge_request_attrs
(
pipeline
.
merge_request
),
user:
pipeline
.
user
.
try
(
:hook_attrs
),
project:
pipeline
.
project
.
hook_attrs
(
backward:
false
),
commit:
pipeline
.
commit
.
try
(
:hook_attrs
),
...
...
@@ -23,6 +24,7 @@ module Gitlab
tag:
pipeline
.
tag
,
sha:
pipeline
.
sha
,
before_sha:
pipeline
.
before_sha
,
source:
pipeline
.
source
,
status:
pipeline
.
status
,
detailed_status:
pipeline
.
detailed_status
(
nil
).
label
,
stages:
pipeline
.
stages_names
,
...
...
@@ -33,6 +35,21 @@ module Gitlab
}
end
def
merge_request_attrs
(
merge_request
)
{
id:
merge_request
.
id
,
iid:
merge_request
.
iid
,
title:
merge_request
.
title
,
source_branch:
merge_request
.
source_branch
,
source_project_id:
merge_request
.
source_project_id
,
target_branch:
merge_request
.
target_branch
,
target_project_id:
merge_request
.
target_project_id
,
state:
merge_request
.
state
,
merge_status:
merge_request
.
merge_status
,
url:
Gitlab
::
UrlBuilder
.
build
(
merge_request
)
}
end
def
build_hook_attrs
(
build
)
{
id:
build
.
id
,
...
...
spec/lib/gitlab/data_builder/pipeline_spec.rb
View file @
5fbbcbca
...
...
@@ -28,12 +28,14 @@ describe Gitlab::DataBuilder::Pipeline do
expect
(
attributes
[
:sha
]).
to
eq
(
pipeline
.
sha
)
expect
(
attributes
[
:tag
]).
to
eq
(
pipeline
.
tag
)
expect
(
attributes
[
:id
]).
to
eq
(
pipeline
.
id
)
expect
(
attributes
[
:source
]).
to
eq
(
pipeline
.
source
)
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
))
expect
(
data
[
:merge_request
]).
to
be_nil
end
context
'pipeline without variables'
do
...
...
@@ -60,6 +62,22 @@ describe Gitlab::DataBuilder::Pipeline do
it
'returns a source ref'
do
expect
(
attributes
[
:ref
]).
to
eq
(
merge_request
.
source_branch
)
end
it
'returns merge request'
do
merge_request_attrs
=
data
[
:merge_request
]
expect
(
merge_request_attrs
).
to
be_a
(
Hash
)
expect
(
merge_request_attrs
[
:id
]).
to
eq
(
merge_request
.
id
)
expect
(
merge_request_attrs
[
:iid
]).
to
eq
(
merge_request
.
iid
)
expect
(
merge_request_attrs
[
:title
]).
to
eq
(
merge_request
.
title
)
expect
(
merge_request_attrs
[
:source_branch
]).
to
eq
(
merge_request
.
source_branch
)
expect
(
merge_request_attrs
[
:source_project_id
]).
to
eq
(
merge_request
.
source_project_id
)
expect
(
merge_request_attrs
[
:target_branch
]).
to
eq
(
merge_request
.
target_branch
)
expect
(
merge_request_attrs
[
:target_project_id
]).
to
eq
(
merge_request
.
target_project_id
)
expect
(
merge_request_attrs
[
:state
]).
to
eq
(
merge_request
.
state
)
expect
(
merge_request_attrs
[
:merge_status
]).
to
eq
(
merge_request
.
merge_status
)
expect
(
merge_request_attrs
[
:url
]).
to
eq
(
"http://localhost/
#{
merge_request
.
target_project
.
full_path
}
/merge_requests/
#{
merge_request
.
iid
}
"
)
end
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