Merge remote-tracking branch 'origin/master' into pullinprivate
Conflicts: workers/dockerfilebuild.py
This commit is contained in:
commit
d67a1cddc2
14 changed files with 96 additions and 32 deletions
|
@ -11,6 +11,7 @@ from endpoints.common import start_build
|
|||
from endpoints.trigger import BuildTrigger
|
||||
from data import model
|
||||
from auth.permissions import ModifyRepositoryPermission
|
||||
from data.buildlogs import BuildStatusRetrievalError
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -56,11 +57,17 @@ def trigger_view(trigger):
|
|||
|
||||
|
||||
def build_status_view(build_obj, can_write=False):
|
||||
status = build_logs.get_status(build_obj.uuid)
|
||||
phase = build_obj.phase
|
||||
try:
|
||||
status = build_logs.get_status(build_obj.uuid)
|
||||
except BuildStatusRetrievalError:
|
||||
status = {}
|
||||
phase = 'cannot_load'
|
||||
|
||||
logger.debug('Can write: %s job_config: %s', can_write, build_obj.job_config)
|
||||
resp = {
|
||||
'id': build_obj.uuid,
|
||||
'phase': build_obj.phase if status else 'cannot_load',
|
||||
'phase': phase,
|
||||
'started': format_date(build_obj.started),
|
||||
'display_name': build_obj.display_name,
|
||||
'status': status or {},
|
||||
|
@ -202,7 +209,10 @@ class RepositoryBuildLogs(RepositoryParamResource):
|
|||
|
||||
start = int(request.args.get('start', 0))
|
||||
|
||||
count, logs = build_logs.get_log_entries(build.uuid, start)
|
||||
try:
|
||||
count, logs = build_logs.get_log_entries(build.uuid, start)
|
||||
except BuildStatusRetrievalError:
|
||||
count, logs = (0, [])
|
||||
|
||||
response_obj.update({
|
||||
'start': start,
|
||||
|
|
|
@ -13,7 +13,8 @@ from endpoints.api.build import (build_status_view, trigger_view, RepositoryBuil
|
|||
get_trigger_config)
|
||||
from endpoints.common import start_build
|
||||
from endpoints.trigger import (BuildTrigger as BuildTriggerBase, TriggerDeactivationException,
|
||||
TriggerActivationException, EmptyRepositoryException)
|
||||
TriggerActivationException, EmptyRepositoryException,
|
||||
RepositoryReadException)
|
||||
from data import model
|
||||
from auth.permissions import UserAdminPermission, AdministerOrganizationPermission
|
||||
from util.names import parse_robot_username
|
||||
|
@ -117,9 +118,14 @@ class BuildTriggerSubdirs(RepositoryParamResource):
|
|||
'status': 'success'
|
||||
}
|
||||
except EmptyRepositoryException as exc:
|
||||
return {
|
||||
'status': 'success',
|
||||
'subdir': []
|
||||
}
|
||||
except RepositoryReadException as exc:
|
||||
return {
|
||||
'status': 'error',
|
||||
'message': exc.msg
|
||||
'message': exc.message
|
||||
}
|
||||
else:
|
||||
raise Unauthorized()
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import logging
|
||||
import urlparse
|
||||
import json
|
||||
import string
|
||||
|
||||
from flask import make_response, render_template, request
|
||||
from flask.ext.login import login_user, UserMixin
|
||||
from flask.ext.principal import identity_changed
|
||||
from random import SystemRandom
|
||||
|
||||
from data import model
|
||||
from data.queue import dockerfile_build_queue
|
||||
|
@ -83,8 +85,13 @@ def handle_dme(ex):
|
|||
return make_response(json.dumps({'message': ex.message}), 400)
|
||||
|
||||
|
||||
def random_string():
|
||||
random = SystemRandom()
|
||||
return ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(8)])
|
||||
|
||||
def render_page_template(name, **kwargs):
|
||||
resp = make_response(render_template(name, route_data=json.dumps(get_route_data()), **kwargs))
|
||||
resp = make_response(render_template(name, route_data=json.dumps(get_route_data()),
|
||||
cache_buster=random_string(), **kwargs))
|
||||
resp.headers['X-FRAME-OPTIONS'] = 'DENY'
|
||||
return resp
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ class ValidationRequestException(Exception):
|
|||
class EmptyRepositoryException(Exception):
|
||||
pass
|
||||
|
||||
class RepositoryReadException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class BuildTrigger(object):
|
||||
def __init__(self):
|
||||
|
@ -209,9 +212,12 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
return [os.path.dirname(elem.path) for elem in commit_tree.tree
|
||||
if (elem.type == u'blob' and
|
||||
os.path.basename(elem.path) == u'Dockerfile')]
|
||||
except GithubException:
|
||||
msg = 'Unable to list contents of repository: %s' % source
|
||||
raise EmptyRepositoryException(msg)
|
||||
except GithubException as ge:
|
||||
message = ge.data.get('message', 'Unable to list contents of repository: %s' % source)
|
||||
if message == 'Branch not found':
|
||||
raise EmptyRepositoryException()
|
||||
|
||||
raise RepositoryReadException(message)
|
||||
|
||||
@staticmethod
|
||||
def _prepare_build(config, repo, commit_sha, build_name, ref):
|
||||
|
|
Reference in a new issue