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
d7fa9952
Commit
d7fa9952
authored
Dec 04, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'prevent-500-test-webhook' into 'master'
Prevent 500 test webhook Fixes #1803 See merge request !1299
parents
e1f1e062
db2edff9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
app/controllers/projects/hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+1
-0
app/models/hooks/web_hook.rb
app/models/hooks/web_hook.rb
+7
-1
app/services/test_hook_service.rb
app/services/test_hook_service.rb
+0
-3
No files found.
app/controllers/projects/hooks_controller.rb
View file @
d7fa9952
...
@@ -26,6 +26,7 @@ class Projects::HooksController < Projects::ApplicationController
...
@@ -26,6 +26,7 @@ class Projects::HooksController < Projects::ApplicationController
def
test
def
test
if
!
@project
.
empty_repo?
if
!
@project
.
empty_repo?
status
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
status
=
TestHookService
.
new
.
execute
(
hook
,
current_user
)
if
status
if
status
flash
[
:notice
]
=
'Hook successfully executed.'
flash
[
:notice
]
=
'Hook successfully executed.'
else
else
...
...
app/models/hooks/web_hook.rb
View file @
d7fa9952
...
@@ -32,7 +32,10 @@ class WebHook < ActiveRecord::Base
...
@@ -32,7 +32,10 @@ class WebHook < ActiveRecord::Base
def
execute
(
data
)
def
execute
(
data
)
parsed_url
=
URI
.
parse
(
url
)
parsed_url
=
URI
.
parse
(
url
)
if
parsed_url
.
userinfo
.
blank?
if
parsed_url
.
userinfo
.
blank?
WebHook
.
post
(
url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
},
verify:
false
)
WebHook
.
post
(
url
,
body:
data
.
to_json
,
headers:
{
"Content-Type"
=>
"application/json"
},
verify:
false
)
else
else
post_url
=
url
.
gsub
(
"
#{
parsed_url
.
userinfo
}
@"
,
""
)
post_url
=
url
.
gsub
(
"
#{
parsed_url
.
userinfo
}
@"
,
""
)
auth
=
{
auth
=
{
...
@@ -45,6 +48,9 @@ class WebHook < ActiveRecord::Base
...
@@ -45,6 +48,9 @@ class WebHook < ActiveRecord::Base
verify:
false
,
verify:
false
,
basic_auth:
auth
)
basic_auth:
auth
)
end
end
rescue
SocketError
,
Errno
::
ECONNREFUSED
=>
e
logger
.
error
(
"WebHook Error =>
#{
e
}
"
)
false
end
end
def
async_execute
(
data
)
def
async_execute
(
data
)
...
...
app/services/test_hook_service.rb
View file @
d7fa9952
...
@@ -2,8 +2,5 @@ class TestHookService
...
@@ -2,8 +2,5 @@ class TestHookService
def
execute
(
hook
,
current_user
)
def
execute
(
hook
,
current_user
)
data
=
GitPushService
.
new
.
sample_data
(
hook
.
project
,
current_user
)
data
=
GitPushService
.
new
.
sample_data
(
hook
.
project
,
current_user
)
hook
.
execute
(
data
)
hook
.
execute
(
data
)
true
rescue
SocketError
false
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