##// END OF EJS Templates
events: expose shadow repo build url.
marcink -
r2582:2d4f0f93 default
parent child Browse files
Show More
@@ -56,6 +56,8 b' class PullRequestEvent(RepoEvent):'
56 self.pullrequest, request=self.request),
56 self.pullrequest, request=self.request),
57 'permalink_url': PullRequestModel().get_url(
57 'permalink_url': PullRequestModel().get_url(
58 self.pullrequest, request=self.request, permalink=True),
58 self.pullrequest, request=self.request, permalink=True),
59 'shadow_url': PullRequestModel().get_shadow_clone_url(
60 self.pullrequest, request=self.request),
59 'status': self.pullrequest.calculated_review_status(),
61 'status': self.pullrequest.calculated_review_status(),
60 'commits': commits,
62 'commits': commits,
61 }
63 }
@@ -132,6 +132,7 b' CI_URL_VARS = ['
132 # pr events vars
132 # pr events vars
133 'pull_request_id',
133 'pull_request_id',
134 'pull_request_url',
134 'pull_request_url',
135 'pull_request_shadow_url',
135
136
136 # user who triggers the call
137 # user who triggers the call
137 'username',
138 'username',
@@ -56,6 +56,7 b' WEBHOOK_URL_VARS = ['
56 # pr events vars
56 # pr events vars
57 'pull_request_id',
57 'pull_request_id',
58 'pull_request_url',
58 'pull_request_url',
59 'pull_request_shadow_url',
59
60
60 # user who triggers the call
61 # user who triggers the call
61 'username',
62 'username',
@@ -156,7 +157,8 b' class WebhookHandler(object):'
156 'register webhook call(%s) to url %s', event, url)
157 'register webhook call(%s) to url %s', event, url)
157 url = string.Template(url).safe_substitute(
158 url = string.Template(url).safe_substitute(
158 pull_request_id=data['pullrequest']['pull_request_id'],
159 pull_request_id=data['pullrequest']['pull_request_id'],
159 pull_request_url=data['pullrequest']['url'])
160 pull_request_url=data['pullrequest']['url'],
161 pull_request_shadow_url=data['pullrequest']['shadow_url'],)
160 return [(url, self.secret_token, self.headers, data)]
162 return [(url, self.secret_token, self.headers, data)]
161
163
162 def __call__(self, event, data):
164 def __call__(self, event, data):
@@ -365,6 +367,7 b' def post_to_webhook(url_calls, settings)'
365 rhodecode.__version__)
367 rhodecode.__version__)
366 } # updated below with custom ones, allows override
368 } # updated below with custom ones, allows override
367
369
370 auth = get_auth(settings)
368 for url, token, headers, data in url_calls:
371 for url, token, headers, data in url_calls:
369 req_session = requests.Session()
372 req_session = requests.Session()
370 req_session.mount( # retry max N times
373 req_session.mount( # retry max N times
@@ -375,7 +378,6 b' def post_to_webhook(url_calls, settings)'
375
378
376 headers = headers or {}
379 headers = headers or {}
377 call_headers.update(headers)
380 call_headers.update(headers)
378 auth = get_auth(settings)
379
381
380 log.debug('calling Webhook with method: %s, and auth:%s',
382 log.debug('calling Webhook with method: %s, and auth:%s',
381 call_method, auth)
383 call_method, auth)
@@ -1063,7 +1063,7 b' class PullRequestModel(BaseModel):'
1063 repo_name=safe_str(pull_request.target_repo.repo_name),
1063 repo_name=safe_str(pull_request.target_repo.repo_name),
1064 pull_request_id=pull_request.pull_request_id,)
1064 pull_request_id=pull_request.pull_request_id,)
1065
1065
1066 def get_shadow_clone_url(self, pull_request):
1066 def get_shadow_clone_url(self, pull_request, request=None):
1067 """
1067 """
1068 Returns qualified url pointing to the shadow repository. If this pull
1068 Returns qualified url pointing to the shadow repository. If this pull
1069 request is closed there is no shadow repository and ``None`` will be
1069 request is closed there is no shadow repository and ``None`` will be
@@ -1072,7 +1072,7 b' class PullRequestModel(BaseModel):'
1072 if pull_request.is_closed():
1072 if pull_request.is_closed():
1073 return None
1073 return None
1074 else:
1074 else:
1075 pr_url = urllib.unquote(self.get_url(pull_request))
1075 pr_url = urllib.unquote(self.get_url(pull_request, request=request))
1076 return safe_unicode('{pr_url}/repository'.format(pr_url=pr_url))
1076 return safe_unicode('{pr_url}/repository'.format(pr_url=pr_url))
1077
1077
1078 def notify_reviewers(self, pull_request, reviewers_ids):
1078 def notify_reviewers(self, pull_request, reviewers_ids):
General Comments 0
You need to be logged in to leave comments. Login now