diff --git a/buildman/component/buildcomponent.py b/buildman/component/buildcomponent.py index a59cb421a..c4c8544d1 100644 --- a/buildman/component/buildcomponent.py +++ b/buildman/component/buildcomponent.py @@ -139,7 +139,7 @@ class BuildComponent(BaseComponent): if build_job.repo_build.trigger.private_key is not None: build_arguments['git'] = { 'url': build_config['trigger_metadata'].get('git_url', ''), - 'sha': build_config['trigger_metadata'].get('commit_sha', ''), + 'sha': BuildComponent._commit_sha(build_config), 'private_key': build_job.repo_build.trigger.private_key, } @@ -149,6 +149,14 @@ class BuildComponent(BaseComponent): self.call("io.quay.builder.build", **build_arguments).add_done_callback(self._build_complete) + @staticmethod + def _commit_sha(build_config): + """ Determines whether the metadata is using an old schema or not and returns the commit. """ + commit_sha = build_config['trigger_metadata'].get('commit', '') + old_commit_sha = build_config['trigger_metadata'].get('commit_sha', '') + return commit_sha or old_commit_sha + + @staticmethod def _total_completion(statuses, total_images): """ Returns the current amount completion relative to the total completion of a build. """ diff --git a/endpoints/trigger.py b/endpoints/trigger.py index 692c23990..89a74cb2f 100644 --- a/endpoints/trigger.py +++ b/endpoints/trigger.py @@ -478,7 +478,7 @@ class BitbucketBuildTrigger(BuildTriggerHandler): } metadata = { - 'commit_sha': commit_sha, + 'commit': commit_sha, 'ref': ref, 'default_branch': default_branch, 'git_url': 'git@bitbucket.org:%s/%s.git' % (namespace, name), @@ -822,7 +822,7 @@ class GithubBuildTrigger(BuildTriggerHandler): # Build and set the metadata. metadata = { - 'commit_sha': commit_sha, + 'commit': commit_sha, 'ref': ref, 'default_branch': repo.default_branch, 'git_url': repo.ssh_url, @@ -936,7 +936,7 @@ class CustomBuildTrigger(BuildTriggerHandler): 'commit': { 'type': 'string', 'description': 'first 7 characters of the SHA-1 identifier for a git commit', - 'pattern': '^([A-Fa-f0-9]{7})$', + 'pattern': '^([A-Fa-f0-9]{7,})$', }, 'ref': { 'type': 'string', @@ -1057,7 +1057,7 @@ class CustomBuildTrigger(BuildTriggerHandler): config = self.config metadata = { - 'commit_sha': commit_sha, + 'commit': commit_sha, 'git_url': config['build_source'], } @@ -1307,7 +1307,7 @@ class GitLabBuildTrigger(BuildTriggerHandler): author = None metadata = { - 'commit_sha': commit['id'], + 'commit': commit['id'], 'ref': ref, 'default_branch': repo['default_branch'], 'git_url': repo['ssh_url_to_repo'], diff --git a/initdb.py b/initdb.py index b67d0440e..81d1fc978 100644 --- a/initdb.py +++ b/initdb.py @@ -439,7 +439,7 @@ def populate_database(): 'docker_tags': ['latest'], 'build_subdir': '', 'trigger_metadata': { - 'commit_sha': '3482adc5822c498e8f7db2e361e8d57b3d77ddd9', + 'commit': '3482adc5822c498e8f7db2e361e8d57b3d77ddd9', 'ref': 'refs/heads/master', 'default_branch': 'master' } diff --git a/static/directives/triggered-build-description.html b/static/directives/triggered-build-description.html index d645bb3e4..1339df82b 100644 --- a/static/directives/triggered-build-description.html +++ b/static/directives/triggered-build-description.html @@ -21,14 +21,14 @@
Triggered by commit + commit-sha="TriggerService.getCommitSHA(build.trigger_metadata)">
+ target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', TriggerService.getCommitSHA(build.trigger_metadata)) }}"> {{ build.trigger_metadata.commit_info.message }}
@@ -46,7 +46,7 @@