Show More
@@ -118,8 +118,7 b' class WebhookSettingsSchema(colander.Sch' | |||||
118 | method_type = colander.SchemaNode( |
|
118 | method_type = colander.SchemaNode( | |
119 | colander.String(), |
|
119 | colander.String(), | |
120 | title=_('Call Method'), |
|
120 | title=_('Call Method'), | |
121 |
description=_('Select |
|
121 | description=_('Select a HTTP method to use when calling the Webhook.'), | |
122 | 'with POST, GET or PUT.'), |
|
|||
123 | default='post', |
|
122 | default='post', | |
124 | missing='', |
|
123 | missing='', | |
125 | widget=deform.widget.RadioChoiceWidget( |
|
124 | widget=deform.widget.RadioChoiceWidget( | |
@@ -187,8 +186,7 b' class WebhookIntegrationType(Integration' | |||||
187 | handler = WebhookDataHandler(template_url, headers) |
|
186 | handler = WebhookDataHandler(template_url, headers) | |
188 |
|
187 | |||
189 | url_calls = handler(event, data) |
|
188 | url_calls = handler(event, data) | |
190 | log.debug('webhook: calling following urls: %s', |
|
189 | log.debug('webhook: calling following urls: %s', [x[0] for x in url_calls]) | |
191 | [x[0] for x in url_calls]) |
|
|||
192 |
|
190 | |||
193 | run_task(post_to_webhook, url_calls, self.settings) |
|
191 | run_task(post_to_webhook, url_calls, self.settings) | |
194 |
|
192 | |||
@@ -202,37 +200,39 b' def post_to_webhook(url_calls, settings)' | |||||
202 | 'actor_ip': u'192.168.157.1', |
|
200 | 'actor_ip': u'192.168.157.1', | |
203 | 'name': 'repo-push', |
|
201 | 'name': 'repo-push', | |
204 | 'push': {'branches': [{'name': u'default', |
|
202 | 'push': {'branches': [{'name': u'default', | |
205 | 'url': 'http://rc.local:8080/hg-repo/changelog?branch=default'}], |
|
203 | 'url': 'http://rc.local:8080/hg-repo/changelog?branch=default'}], | |
206 | 'commits': [{'author': u'Marcin Kuzminski <marcin@rhodecode.com>', |
|
204 | 'commits': [{'author': u'Marcin Kuzminski <marcin@rhodecode.com>', | |
207 | 'branch': u'default', |
|
205 | 'branch': u'default', | |
208 | 'date': datetime.datetime(2017, 11, 30, 12, 59, 48), |
|
206 | 'date': datetime.datetime(2017, 11, 30, 12, 59, 48), | |
209 | 'issues': [], |
|
207 | 'issues': [], | |
210 | 'mentions': [], |
|
208 | 'mentions': [], | |
211 | 'message': u'commit Thu 30 Nov 2017 13:59:48 CET', |
|
209 | 'message': u'commit Thu 30 Nov 2017 13:59:48 CET', | |
212 | 'message_html': u'commit Thu 30 Nov 2017 13:59:48 CET', |
|
210 | 'message_html': u'commit Thu 30 Nov 2017 13:59:48 CET', | |
213 | 'message_html_title': u'commit Thu 30 Nov 2017 13:59:48 CET', |
|
211 | 'message_html_title': u'commit Thu 30 Nov 2017 13:59:48 CET', | |
214 | 'parents': [{'raw_id': '431b772a5353dad9974b810dd3707d79e3a7f6e0'}], |
|
212 | 'parents': [{'raw_id': '431b772a5353dad9974b810dd3707d79e3a7f6e0'}], | |
215 | 'permalink_url': u'http://rc.local:8080/_7/changeset/a815cc738b9651eb5ffbcfb1ce6ccd7c701a5ddf', |
|
213 | 'permalink_url': u'http://rc.local:8080/_7/changeset/a815cc738b9651eb5ffbcfb1ce6ccd7c701a5ddf', | |
216 | 'raw_id': 'a815cc738b9651eb5ffbcfb1ce6ccd7c701a5ddf', |
|
214 | 'raw_id': 'a815cc738b9651eb5ffbcfb1ce6ccd7c701a5ddf', | |
217 | 'refs': {'bookmarks': [], 'branches': [u'default'], 'tags': [u'tip']}, |
|
215 | 'refs': {'bookmarks': [], | |
218 | 'reviewers': [], |
|
216 | 'branches': [u'default'], | |
219 | 'revision': 9L, |
|
217 | 'tags': [u'tip']}, | |
220 | 'short_id': 'a815cc738b96', |
|
218 | 'reviewers': [], | |
221 | 'url': u'http://rc.local:8080/hg-repo/changeset/a815cc738b9651eb5ffbcfb1ce6ccd7c701a5ddf'}], |
|
219 | 'revision': 9L, | |
222 | 'issues': {}}, |
|
220 | 'short_id': 'a815cc738b96', | |
|
221 | 'url': u'http://rc.local:8080/hg-repo/changeset/a815cc738b9651eb5ffbcfb1ce6ccd7c701a5ddf'}], | |||
|
222 | 'issues': {}}, | |||
223 | 'repo': {'extra_fields': '', |
|
223 | 'repo': {'extra_fields': '', | |
224 | 'permalink_url': u'http://rc.local:8080/_7', |
|
224 | 'permalink_url': u'http://rc.local:8080/_7', | |
225 | 'repo_id': 7, |
|
225 | 'repo_id': 7, | |
226 | 'repo_name': u'hg-repo', |
|
226 | 'repo_name': u'hg-repo', | |
227 | 'repo_type': u'hg', |
|
227 | 'repo_type': u'hg', | |
228 | 'url': u'http://rc.local:8080/hg-repo'}, |
|
228 | 'url': u'http://rc.local:8080/hg-repo'}, | |
229 | 'server_url': u'http://rc.local:8080', |
|
229 | 'server_url': u'http://rc.local:8080', | |
230 | 'utc_timestamp': datetime.datetime(2017, 11, 30, 13, 0, 1, 569276) |
|
230 | 'utc_timestamp': datetime.datetime(2017, 11, 30, 13, 0, 1, 569276) | |
|
231 | } | |||
|
232 | """ | |||
231 |
|
233 | |||
232 | """ |
|
|||
233 | call_headers = { |
|
234 | call_headers = { | |
234 | 'User-Agent': 'RhodeCode-webhook-caller/{}'.format( |
|
235 | 'User-Agent': 'RhodeCode-webhook-caller/{}'.format(rhodecode.__version__) | |
235 | rhodecode.__version__) |
|
|||
236 | } # updated below with custom ones, allows override |
|
236 | } # updated below with custom ones, allows override | |
237 |
|
237 | |||
238 | auth = get_auth(settings) |
|
238 | auth = get_auth(settings) | |
@@ -247,8 +247,7 b' def post_to_webhook(url_calls, settings)' | |||||
247 | headers = headers or {} |
|
247 | headers = headers or {} | |
248 | call_headers.update(headers) |
|
248 | call_headers.update(headers) | |
249 |
|
249 | |||
250 | log.debug('calling Webhook with method: %s, and auth:%s', |
|
250 | log.debug('calling Webhook with method: %s, and auth:%s', call_method, auth) | |
251 | call_method, auth) |
|
|||
252 | if settings.get('log_data'): |
|
251 | if settings.get('log_data'): | |
253 | log.debug('calling webhook with data: %s', data) |
|
252 | log.debug('calling webhook with data: %s', data) | |
254 | resp = call_method(url, json={ |
|
253 | resp = call_method(url, json={ |
General Comments 0
You need to be logged in to leave comments.
Login now