Get basic support for GitLab working in the UI
This commit is contained in:
parent
e3aededcbc
commit
f091aaa07e
4 changed files with 33 additions and 7 deletions
|
@ -1168,6 +1168,8 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
def list_build_sources(self):
|
||||
gl_client = self._get_authorized_client()
|
||||
current_user = gl_client.currentuser()
|
||||
if current_user is False:
|
||||
raise RepositoryReadException('Unable to get current user')
|
||||
|
||||
repositories = gl_client.getprojects()
|
||||
if repositories is False:
|
||||
|
@ -1178,7 +1180,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
owner = repo['namespace']['name']
|
||||
if not owner in namespaces:
|
||||
namespaces[owner] = {
|
||||
'personal': owner == current_user.username,
|
||||
'personal': owner == current_user['username'],
|
||||
'repos': [],
|
||||
'info': {
|
||||
'name': owner,
|
||||
|
@ -1244,7 +1246,10 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
def load_dockerfile_contents(self):
|
||||
gl_client = self._get_authorized_client()
|
||||
subdir = self.config.get('subdir', '')
|
||||
path = subdir + '/Dockerfile' if subdir else 'Dockerfile'
|
||||
if subdir == '/':
|
||||
subdir = ''
|
||||
|
||||
path = subdir + 'Dockerfile' if subdir else 'Dockerfile'
|
||||
|
||||
repository = gl_client.getproject(self.config['build_source'])
|
||||
if repository is False:
|
||||
|
@ -1254,6 +1259,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
branches = find_matching_branches(self.config, branches)
|
||||
if branches == []:
|
||||
return None
|
||||
|
||||
branch_name = branches[0]
|
||||
if repository['default_branch'] in branches:
|
||||
branch_name = repository['default_branch']
|
||||
|
@ -1261,6 +1267,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
contents = gl_client.getrawfile(repository['id'], branch_name, path)
|
||||
if contents is False:
|
||||
return None
|
||||
|
||||
return contents
|
||||
|
||||
def list_field_values(self, field_name):
|
||||
|
@ -1277,7 +1284,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
return []
|
||||
|
||||
if field_name == 'tag_name':
|
||||
tags = gl_client.getall(gl_client.getrepositorytags(repo['id']))
|
||||
tags = gl_client.getrepositorytags(repo['id'])
|
||||
if tags is False:
|
||||
return []
|
||||
return [tag['name'] for tag in tags]
|
||||
|
@ -1324,14 +1331,14 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
|||
metadata['commit_info']['committer'] = {
|
||||
'username': committer['username'],
|
||||
'avatar_url': committer['avatar_url'],
|
||||
'url': client.host + '/' + committer['username'],
|
||||
'url': gl_client.host + '/' + committer['username'],
|
||||
}
|
||||
|
||||
if author is not None:
|
||||
metadata['commit_info']['author'] = {
|
||||
'username': author['username'],
|
||||
'avatar_url': author['avatar_url'],
|
||||
'url': client.host + '/' + author['username']
|
||||
'url': gl_client.host + '/' + author['username']
|
||||
}
|
||||
|
||||
prepared = PreparedBuild(self.trigger)
|
||||
|
|
Reference in a new issue