Initialize github auth in getGitUrl if needed

The executors and mergers don't initialize the github authentication
upfront. However they call getGitUrl which gets unauthenticated if we
run as a github app. So check and initialize the authentication and
installation map.

Change-Id: If05b9f8660cab1d78ac82ea0455aa24721f3a7e2
This commit is contained in:
Tobias Henkel
2017-12-15 16:13:12 +01:00
parent 42f7d6f100
commit 8904f17c32

View File

@@ -790,6 +790,12 @@ class GithubConnection(BaseConnection):
if self.git_ssh_key:
return 'ssh://git@%s/%s.git' % (self.server, project.name)
# if app_id is configured but self.app_id is empty we are not
# authenticated yet against github as app
if not self.app_id and self.connection_config.get('app_id', None):
self._authenticateGithubAPI()
self._prime_installation_map()
if self.app_id:
installation_key = self._get_installation_key(project.name)
return 'https://x-access-token:%s@%s/%s' % (installation_key,