add git_url to metadata, add git to buildargs
This commit is contained in:
parent
f6f93e9079
commit
b851986cf5
2 changed files with 17 additions and 8 deletions
|
@ -107,8 +107,6 @@ class BuildComponent(BaseComponent):
|
|||
|
||||
# Parse the build queue item into build arguments.
|
||||
# build_package: URL to the build package to download and untar/unzip.
|
||||
# git_url: URL to clone a repository if there's no buildpack.
|
||||
# git_key: ssh key to clone a repository.
|
||||
# sub_directory: The location within the build package of the Dockerfile and the build context.
|
||||
# repository: The repository for which this build is occurring.
|
||||
# registry: The registry for which this build is occuring (e.g. 'quay.io', 'staging.quay.io').
|
||||
|
@ -122,17 +120,24 @@ class BuildComponent(BaseComponent):
|
|||
# password: The password for pulling the base image (if any).
|
||||
build_arguments = {
|
||||
'build_package': buildpack_url,
|
||||
'git_url': build_config.get('git_url', ''),
|
||||
'git_key': build_config.get('git_key', ''),
|
||||
'sub_directory': build_config.get('build_subdir', ''),
|
||||
'repository': repository_name,
|
||||
'registry': self.registry_hostname,
|
||||
'pull_token': build_job.repo_build.access_token.code,
|
||||
'push_token': build_job.repo_build.access_token.code,
|
||||
'tag_names': build_config.get('docker_tags', ['latest']),
|
||||
'base_image': base_image_information
|
||||
'base_image': base_image_information,
|
||||
}
|
||||
|
||||
# If the trigger has a private key, it's using git, thus we should add
|
||||
# git data to the build args.
|
||||
if build_job.repo_build.trigger.private_key is not None:
|
||||
build_arguments['git'] = {
|
||||
'url': build_config['trigger_metadata']['git_url'],
|
||||
'sha': build_config['trigger_metadata']['commit_sha'],
|
||||
'private_key': build_job.repo_build.trigger.private_key,
|
||||
}
|
||||
|
||||
# Invoke the build.
|
||||
logger.debug('Invoking build: %s', self.builder_realm)
|
||||
logger.debug('With Arguments: %s', build_arguments)
|
||||
|
|
|
@ -371,8 +371,9 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
|
||||
return commit_info
|
||||
|
||||
# TODO(jzelinskie): update this to support both kinds of triggers
|
||||
@staticmethod
|
||||
def _prepare_build(config, repo, commit_sha, build_name, ref):
|
||||
def _prepare_build(config, repo, commit_sha, build_name, ref, git_url):
|
||||
# Prepare the download and upload URLs
|
||||
archive_link = repo.get_archive_link('tarball', commit_sha)
|
||||
download_archive = client.get(archive_link, stream=True)
|
||||
|
@ -422,6 +423,7 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
'commit_sha': commit_sha,
|
||||
'ref': ref,
|
||||
'default_branch': repo.default_branch,
|
||||
'git_url': git_url,
|
||||
}
|
||||
|
||||
# add the commit info.
|
||||
|
@ -447,6 +449,7 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
ref = payload['ref']
|
||||
commit_sha = payload['head_commit']['id']
|
||||
commit_message = payload['head_commit'].get('message', '')
|
||||
git_url = payload['repository']['git_url']
|
||||
|
||||
if 'branchtag_regex' in config:
|
||||
try:
|
||||
|
@ -471,7 +474,7 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
logger.debug('Github repo: %s', repo)
|
||||
|
||||
return GithubBuildTrigger._prepare_build(config, repo, commit_sha,
|
||||
short_sha, ref)
|
||||
short_sha, ref, git_url)
|
||||
|
||||
def manual_start(self, auth_token, config, run_parameters=None):
|
||||
try:
|
||||
|
@ -485,8 +488,9 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
branch_sha = branch.commit.sha
|
||||
short_sha = GithubBuildTrigger.get_display_name(branch_sha)
|
||||
ref = 'refs/heads/%s' % (branch_name)
|
||||
git_url = repo.git_url
|
||||
|
||||
return self._prepare_build(config, repo, branch_sha, short_sha, ref)
|
||||
return self._prepare_build(config, repo, branch_sha, short_sha, ref, git_url)
|
||||
except GithubException as ghe:
|
||||
raise TriggerStartException(ghe.data['message'])
|
||||
|
||||
|
|
Reference in a new issue