BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f4e0c562
Commit
f4e0c562
authored
May 03, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve documentation and web test for web hooks
I wanted to share what I learned trying to debug web hooks using netcat.
parent
f0c4f727
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+1
-1
web_hook.rb
app/models/hooks/web_hook.rb
+1
-1
web_hooks.md
doc/web_hooks/web_hooks.md
+13
-0
No files found.
app/controllers/projects/hooks_controller.rb
View file @
f4e0c562
...
...
@@ -28,7 +28,7 @@ class Projects::HooksController < Projects::ApplicationController
status
,
message
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
flash
[
:notice
]
=
"Hook successfully executed, HTTP
#{
status
}
#{
message
}
"
else
flash
[
:alert
]
=
"Hook execution failed:
#{
message
}
"
end
...
...
app/models/hooks/web_hook.rb
View file @
f4e0c562
...
...
@@ -59,7 +59,7 @@ class WebHook < ActiveRecord::Base
basic_auth:
auth
)
end
[
(
response
.
code
>=
200
&&
response
.
code
<
300
)
,
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
response
.
to_s
)]
[
response
.
code
,
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
response
.
to_s
)]
rescue
SocketError
,
OpenSSL
::
SSL
::
SSLError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
,
Net
::
OpenTimeout
=>
e
logger
.
error
(
"WebHook Error =>
#{
e
}
"
)
[
false
,
e
.
to_s
]
...
...
doc/web_hooks/web_hooks.md
View file @
f4e0c562
...
...
@@ -13,6 +13,19 @@ You can configure webhooks to listen for specific events like pushes, issues or
Webhooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server.
## Webhook endpoint tips
If you are writing your own endpoint (web server) that will receive
GitLab web hooks keep in mind the following things:
-
Your endpoint should send its HTTP response as fast as possible. If
you wait too long, GitLab may decide the hook failed and retry it.
-
Your endpoint should ALWAYS return a valid HTTP response. If you do
not do this then GitLab will think the hook failed and retry it.
Most HTTP libraries take care of this for you automatically but if
you are writing a low-level hook this is important to remember.
-
GitLab ignores the HTTP status code returned by your endpoint.
## SSL Verification
By default, the SSL certificate of the webhook endpoint is verified based on
...
...
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