Start recording the commit sha and other metadata about github triggered builds. We'll eventually show this information in the UI
This commit is contained in:
parent
4cf18c4591
commit
7c81d90cda
5 changed files with 22 additions and 9 deletions
|
@ -415,13 +415,13 @@ class ActivateBuildTrigger(RepositoryParamResource):
|
|||
try:
|
||||
run_parameters = request.get_json()
|
||||
specs = handler.manual_start(trigger.auth_token, config_dict, run_parameters=run_parameters)
|
||||
dockerfile_id, tags, name, subdir = specs
|
||||
dockerfile_id, tags, name, subdir, metadata = specs
|
||||
|
||||
repo = model.get_repository(namespace, repository)
|
||||
pull_robot_name = model.get_pull_robot_name(trigger)
|
||||
|
||||
build_request = start_build(repo, dockerfile_id, tags, name, subdir, True,
|
||||
pull_robot_name=pull_robot_name)
|
||||
pull_robot_name=pull_robot_name, trigger_metadata=metadata)
|
||||
except TriggerStartException as tse:
|
||||
raise InvalidRequest(tse.message)
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ def check_repository_usage(user_or_org, plan_found):
|
|||
|
||||
|
||||
def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
||||
trigger=None, pull_robot_name=None):
|
||||
trigger=None, pull_robot_name=None, trigger_metadata=None):
|
||||
host = urlparse.urlparse(request.url).netloc
|
||||
repo_path = '%s/%s/%s' % (host, repository.namespace_user.username, repository.name)
|
||||
|
||||
|
@ -223,7 +223,8 @@ def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
|||
job_config = {
|
||||
'docker_tags': tags,
|
||||
'registry': host,
|
||||
'build_subdir': subdir
|
||||
'build_subdir': subdir,
|
||||
'trigger_metadata': trigger_metadata or {}
|
||||
}
|
||||
|
||||
with app.config['DB_TRANSACTION_FACTORY'](db):
|
||||
|
|
|
@ -345,8 +345,10 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
# compute the tag(s)
|
||||
branch = ref.split('/')[-1]
|
||||
tags = {branch}
|
||||
|
||||
if branch == repo.default_branch:
|
||||
tags.add('latest')
|
||||
|
||||
logger.debug('Pushing to tags: %s' % tags)
|
||||
|
||||
# compute the subdir
|
||||
|
@ -354,7 +356,14 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
joined_subdir = os.path.join(tarball_subdir, repo_subdir)
|
||||
logger.debug('Final subdir: %s' % joined_subdir)
|
||||
|
||||
return dockerfile_id, list(tags), build_name, joined_subdir
|
||||
# compute the metadata
|
||||
metadata = {
|
||||
'commit_sha': commit_sha,
|
||||
'ref': ref,
|
||||
'default_branch': repo.default_branch
|
||||
}
|
||||
|
||||
return dockerfile_id, list(tags), build_name, joined_subdir, metadata
|
||||
|
||||
@staticmethod
|
||||
def get_display_name(sha):
|
||||
|
|
|
@ -91,7 +91,7 @@ def build_trigger_webhook(trigger_uuid, **kwargs):
|
|||
try:
|
||||
specs = handler.handle_trigger_request(request, trigger.auth_token,
|
||||
config_dict)
|
||||
dockerfile_id, tags, name, subdir = specs
|
||||
dockerfile_id, tags, name, subdir, metadata = specs
|
||||
|
||||
except ValidationRequestException:
|
||||
# This was just a validation request, we don't need to build anything
|
||||
|
@ -104,7 +104,7 @@ def build_trigger_webhook(trigger_uuid, **kwargs):
|
|||
pull_robot_name = model.get_pull_robot_name(trigger)
|
||||
repo = model.get_repository(namespace, repository)
|
||||
start_build(repo, dockerfile_id, tags, name, subdir, False, trigger,
|
||||
pull_robot_name=pull_robot_name)
|
||||
pull_robot_name=pull_robot_name, trigger_metadata=metadata)
|
||||
|
||||
return make_response('Okay')
|
||||
|
||||
|
|
Reference in a new issue