buildcomponent: handle builds without resource_key
This commit is contained in:
parent
d29c8d60c7
commit
cd1b003ca6
4 changed files with 20 additions and 6 deletions
|
@ -93,6 +93,8 @@ class BuildComponent(BaseComponent):
|
||||||
self._build_failure('Could not load build job information', irbe)
|
self._build_failure('Could not load build job information', irbe)
|
||||||
|
|
||||||
base_image_information = {}
|
base_image_information = {}
|
||||||
|
buildpack_url = ""
|
||||||
|
if build_job.repo_build.resource_key is not None:
|
||||||
buildpack_url = self.user_files.get_file_url(build_job.repo_build.resource_key,
|
buildpack_url = self.user_files.get_file_url(build_job.repo_build.resource_key,
|
||||||
requires_cors=False)
|
requires_cors=False)
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ def build_status_view(build_obj, can_write=False):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if can_write:
|
if can_write and build_obj.resource_key is not None:
|
||||||
resp['archive_url'] = user_files.get_file_url(build_obj.resource_key, requires_cors=True)
|
resp['archive_url'] = user_files.get_file_url(build_obj.resource_key, requires_cors=True)
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
|
@ -418,7 +418,7 @@ class ActivateBuildTrigger(RepositoryParamResource):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
run_parameters = request.get_json()
|
run_parameters = request.get_json()
|
||||||
specs = handler.manual_start(trigger.auth_token, config_dict, run_parameters=run_parameters)
|
specs = handler.manual_start(trigger, run_parameters=run_parameters)
|
||||||
dockerfile_id, tags, name, subdir, metadata = specs
|
dockerfile_id, tags, name, subdir, metadata = specs
|
||||||
|
|
||||||
repo = model.get_repository(namespace, repository)
|
repo = model.get_repository(namespace, repository)
|
||||||
|
|
|
@ -4,13 +4,13 @@ import os.path
|
||||||
import tarfile
|
import tarfile
|
||||||
import base64
|
import base64
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
from github import Github, UnknownObjectException, GithubException
|
from github import Github, UnknownObjectException, GithubException
|
||||||
from tempfile import SpooledTemporaryFile
|
from tempfile import SpooledTemporaryFile
|
||||||
|
|
||||||
from app import app, userfiles as user_files, github_trigger
|
from app import app, userfiles as user_files, github_trigger
|
||||||
from util.tarfileappender import TarfileAppender
|
from util.tarfileappender import TarfileAppender
|
||||||
from endpoints.api.build import get_trigger_config
|
|
||||||
|
|
||||||
|
|
||||||
client = app.config['HTTPCLIENT']
|
client = app.config['HTTPCLIENT']
|
||||||
|
@ -147,6 +147,12 @@ class BuildTrigger(object):
|
||||||
def raise_unsupported():
|
def raise_unsupported():
|
||||||
raise io.UnsupportedOperation
|
raise io.UnsupportedOperation
|
||||||
|
|
||||||
|
def get_trigger_config(trigger):
|
||||||
|
try:
|
||||||
|
return json.loads(trigger.config)
|
||||||
|
except:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class GithubBuildTrigger(BuildTrigger):
|
class GithubBuildTrigger(BuildTrigger):
|
||||||
"""
|
"""
|
||||||
|
@ -405,6 +411,9 @@ class GithubBuildTrigger(BuildTrigger):
|
||||||
dockerfile_id = user_files.store_file(appender, TARBALL_MIME)
|
dockerfile_id = user_files.store_file(appender, TARBALL_MIME)
|
||||||
|
|
||||||
logger.debug('Successfully prepared job')
|
logger.debug('Successfully prepared job')
|
||||||
|
else:
|
||||||
|
dockerfile_id = None
|
||||||
|
|
||||||
|
|
||||||
# compute the tag(s)
|
# compute the tag(s)
|
||||||
branch = ref.split('/')[-1]
|
branch = ref.split('/')[-1]
|
||||||
|
@ -417,7 +426,10 @@ class GithubBuildTrigger(BuildTrigger):
|
||||||
|
|
||||||
# compute the subdir
|
# compute the subdir
|
||||||
repo_subdir = config['subdir']
|
repo_subdir = config['subdir']
|
||||||
|
if trigger.private_key is None:
|
||||||
joined_subdir = os.path.join(tarball_subdir, repo_subdir)
|
joined_subdir = os.path.join(tarball_subdir, repo_subdir)
|
||||||
|
else:
|
||||||
|
joined_subdir = repo_subdir
|
||||||
logger.debug('Final subdir: %s', joined_subdir)
|
logger.debug('Final subdir: %s', joined_subdir)
|
||||||
|
|
||||||
# compute the metadata
|
# compute the metadata
|
||||||
|
|
Reference in a new issue