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
aa94066b
Commit
aa94066b
authored
Feb 14, 2020
by
guillaume micouin
Committed by
Mayra Cabrera
Feb 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add avatar_url in job webhook, and email in pipeline webhook
parent
30b55047
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
10 deletions
+44
-10
app/models/user.rb
app/models/user.rb
+2
-1
changelogs/unreleased/24992-add-avatar_url-and-email_user-in_web_hook.yml
...eased/24992-add-avatar_url-and-email_user-in_web_hook.yml
+5
-0
doc/user/project/integrations/webhooks.md
doc/user/project/integrations/webhooks.md
+4
-2
lib/gitlab/data_builder/build.rb
lib/gitlab/data_builder/build.rb
+1
-5
spec/lib/gitlab/data_builder/build_spec.rb
spec/lib/gitlab/data_builder/build_spec.rb
+11
-1
spec/lib/gitlab/data_builder/pipeline_spec.rb
spec/lib/gitlab/data_builder/pipeline_spec.rb
+8
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+13
-0
No files found.
app/models/user.rb
View file @
aa94066b
...
...
@@ -1226,7 +1226,8 @@ class User < ApplicationRecord
{
name:
name
,
username:
username
,
avatar_url:
avatar_url
(
only_path:
false
)
avatar_url:
avatar_url
(
only_path:
false
),
email:
email
}
end
...
...
changelogs/unreleased/24992-add-avatar_url-and-email_user-in_web_hook.yml
0 → 100644
View file @
aa94066b
---
title
:
add avatar_url in job webhook, and email in pipeline webhook
merge_request
:
24992
author
:
Guillaume Micouin
type
:
added
doc/user/project/integrations/webhooks.md
View file @
aa94066b
...
...
@@ -1054,7 +1054,8 @@ X-Gitlab-Event: Pipeline Hook
"user"
:{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80
\u
0026d=identicon"
"avatar_url"
:
"http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80
\u
0026d=identicon"
,
"email"
:
"user_email@gitlab.com"
},
"project"
:{
"id"
:
1
,
...
...
@@ -1243,7 +1244,8 @@ X-Gitlab-Event: Job Hook
"user"
:
{
"id"
:
3
,
"name"
:
"User"
,
"email"
:
"user@gitlab.com"
"email"
:
"user@gitlab.com"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80
\u
0026d=identicon"
},
"commit"
:
{
"id"
:
2366
,
...
...
lib/gitlab/data_builder/build.rb
View file @
aa94066b
...
...
@@ -38,11 +38,7 @@ module Gitlab
project_id:
project
.
id
,
project_name:
project
.
full_name
,
user:
{
id:
user
.
try
(
:id
),
name:
user
.
try
(
:name
),
email:
user
.
try
(
:email
)
},
user:
user
.
try
(
:hook_attrs
),
commit:
{
# note: commit.id is actually the pipeline id
...
...
spec/lib/gitlab/data_builder/build_spec.rb
View file @
aa94066b
...
...
@@ -4,7 +4,8 @@ require 'spec_helper'
describe
Gitlab
::
DataBuilder
::
Build
do
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
)
}
let
(
:build
)
{
create
(
:ci_build
,
:running
,
runner:
runner
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
,
:running
,
runner:
runner
,
user:
user
)
}
describe
'.build'
do
let
(
:data
)
do
...
...
@@ -22,6 +23,15 @@ describe Gitlab::DataBuilder::Build do
it
{
expect
(
data
[
:project_id
]).
to
eq
(
build
.
project
.
id
)
}
it
{
expect
(
data
[
:project_name
]).
to
eq
(
build
.
project
.
full_name
)
}
it
{
expect
(
data
[
:pipeline_id
]).
to
eq
(
build
.
pipeline
.
id
)
}
it
{
expect
(
data
[
:user
]).
to
eq
(
{
name:
user
.
name
,
username:
user
.
username
,
avatar_url:
user
.
avatar_url
(
only_path:
false
),
email:
user
.
email
})
}
it
{
expect
(
data
[
:commit
][
:id
]).
to
eq
(
build
.
pipeline
.
id
)
}
it
{
expect
(
data
[
:runner
][
:id
]).
to
eq
(
build
.
runner
.
id
)
}
it
{
expect
(
data
[
:runner
][
:description
]).
to
eq
(
build
.
runner
.
description
)
}
...
...
spec/lib/gitlab/data_builder/pipeline_spec.rb
View file @
aa94066b
...
...
@@ -11,7 +11,8 @@ describe Gitlab::DataBuilder::Pipeline do
project:
project
,
status:
'success'
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
ref:
project
.
default_branch
,
user:
user
)
end
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
...
...
@@ -37,6 +38,12 @@ describe Gitlab::DataBuilder::Pipeline do
expect
(
build_data
[
:allow_failure
]).
to
eq
(
build
.
allow_failure
)
expect
(
project_data
).
to
eq
(
project
.
hook_attrs
(
backward:
false
))
expect
(
data
[
:merge_request
]).
to
be_nil
expect
(
data
[
:user
]).
to
eq
({
name:
user
.
name
,
username:
user
.
username
,
avatar_url:
user
.
avatar_url
(
only_path:
false
),
email:
user
.
email
})
end
context
'pipeline without variables'
do
...
...
spec/models/user_spec.rb
View file @
aa94066b
...
...
@@ -4200,4 +4200,17 @@ describe User, :do_not_mock_admin_mode do
expect
(
described_class
.
bots
).
to
match_array
([
bot
])
end
end
describe
'#hook_attrs'
do
it
'includes name, username, avatar_url, and email'
do
user
=
create
(
:user
)
user_attributes
=
{
name:
user
.
name
,
username:
user
.
username
,
avatar_url:
user
.
avatar_url
(
only_path:
false
),
email:
user
.
email
}
expect
(
user
.
hook_attrs
).
to
eq
(
user_attributes
)
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