Merge pull request #59 from jzelinskie/custom-git-fix
triggers: metadata.commit_sha -> metadata.commit
This commit is contained in:
commit
63f289a8cb
8 changed files with 25 additions and 13 deletions
|
@ -139,7 +139,7 @@ class BuildComponent(BaseComponent):
|
||||||
if build_job.repo_build.trigger.private_key is not None:
|
if build_job.repo_build.trigger.private_key is not None:
|
||||||
build_arguments['git'] = {
|
build_arguments['git'] = {
|
||||||
'url': build_config['trigger_metadata'].get('git_url', ''),
|
'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,
|
'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)
|
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
|
@staticmethod
|
||||||
def _total_completion(statuses, total_images):
|
def _total_completion(statuses, total_images):
|
||||||
""" Returns the current amount completion relative to the total completion of a build. """
|
""" Returns the current amount completion relative to the total completion of a build. """
|
||||||
|
|
|
@ -478,7 +478,7 @@ class BitbucketBuildTrigger(BuildTriggerHandler):
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
'commit_sha': commit_sha,
|
'commit': commit_sha,
|
||||||
'ref': ref,
|
'ref': ref,
|
||||||
'default_branch': default_branch,
|
'default_branch': default_branch,
|
||||||
'git_url': 'git@bitbucket.org:%s/%s.git' % (namespace, name),
|
'git_url': 'git@bitbucket.org:%s/%s.git' % (namespace, name),
|
||||||
|
@ -822,7 +822,7 @@ class GithubBuildTrigger(BuildTriggerHandler):
|
||||||
|
|
||||||
# Build and set the metadata.
|
# Build and set the metadata.
|
||||||
metadata = {
|
metadata = {
|
||||||
'commit_sha': commit_sha,
|
'commit': commit_sha,
|
||||||
'ref': ref,
|
'ref': ref,
|
||||||
'default_branch': repo.default_branch,
|
'default_branch': repo.default_branch,
|
||||||
'git_url': repo.ssh_url,
|
'git_url': repo.ssh_url,
|
||||||
|
@ -936,7 +936,7 @@ class CustomBuildTrigger(BuildTriggerHandler):
|
||||||
'commit': {
|
'commit': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'description': 'first 7 characters of the SHA-1 identifier for a git commit',
|
'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': {
|
'ref': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
|
@ -1057,7 +1057,7 @@ class CustomBuildTrigger(BuildTriggerHandler):
|
||||||
|
|
||||||
config = self.config
|
config = self.config
|
||||||
metadata = {
|
metadata = {
|
||||||
'commit_sha': commit_sha,
|
'commit': commit_sha,
|
||||||
'git_url': config['build_source'],
|
'git_url': config['build_source'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1307,7 +1307,7 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
||||||
author = None
|
author = None
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
'commit_sha': commit['id'],
|
'commit': commit['id'],
|
||||||
'ref': ref,
|
'ref': ref,
|
||||||
'default_branch': repo['default_branch'],
|
'default_branch': repo['default_branch'],
|
||||||
'git_url': repo['ssh_url_to_repo'],
|
'git_url': repo['ssh_url_to_repo'],
|
||||||
|
|
|
@ -439,7 +439,7 @@ def populate_database():
|
||||||
'docker_tags': ['latest'],
|
'docker_tags': ['latest'],
|
||||||
'build_subdir': '',
|
'build_subdir': '',
|
||||||
'trigger_metadata': {
|
'trigger_metadata': {
|
||||||
'commit_sha': '3482adc5822c498e8f7db2e361e8d57b3d77ddd9',
|
'commit': '3482adc5822c498e8f7db2e361e8d57b3d77ddd9',
|
||||||
'ref': 'refs/heads/master',
|
'ref': 'refs/heads/master',
|
||||||
'default_branch': 'master'
|
'default_branch': 'master'
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
<div class="tbd-content" ng-switch-when="commitsha">
|
<div class="tbd-content" ng-switch-when="commitsha">
|
||||||
Triggered by commit
|
Triggered by commit
|
||||||
<span class="source-commit-link"
|
<span class="source-commit-link"
|
||||||
commit-sha="build.trigger_metadata.commit_sha"></span>
|
commit-sha="TriggerService.getCommitSHA(build.trigger_metadata)"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Full Commit Information -->
|
<!-- Full Commit Information -->
|
||||||
<div class="tbd-content" ng-switch-when="fullcommit">
|
<div class="tbd-content" ng-switch-when="fullcommit">
|
||||||
<div class="commit-message">
|
<div class="commit-message">
|
||||||
<span class="anchor" is-only-text="!TriggerService.getFullLinkTemplate(build, 'commit')"
|
<span class="anchor" is-only-text="!TriggerService.getFullLinkTemplate(build, 'commit')"
|
||||||
target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', build.trigger_metadata.commit_sha) }}">
|
target="_blank" href="{{ TriggerService.getFullLinkTemplate(build, 'commit').replace('{sha}', TriggerService.getCommitSHA(build.trigger_metadata)) }}">
|
||||||
{{ build.trigger_metadata.commit_info.message }}
|
{{ build.trigger_metadata.commit_info.message }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="source-commit-link"
|
<span class="source-commit-link"
|
||||||
commit-sha="build.trigger_metadata.commit_sha"
|
commit-sha="TriggerService.getCommitSHA(build.trigger_metadata)"
|
||||||
url-template="TriggerService.getFullLinkTemplate(build, 'commit')"></span>
|
url-template="TriggerService.getFullLinkTemplate(build, 'commit')"></span>
|
||||||
<span class="source-ref-link"
|
<span class="source-ref-link"
|
||||||
ref="build.trigger_metadata.ref"
|
ref="build.trigger_metadata.ref"
|
||||||
|
|
|
@ -45,7 +45,7 @@ angular.module('quay').directive('repoPanelBuilds', function () {
|
||||||
var commit_sha = null;
|
var commit_sha = null;
|
||||||
|
|
||||||
if (build_info.trigger_metadata) {
|
if (build_info.trigger_metadata) {
|
||||||
commit_sha = build_info.trigger_metadata.commit_sha;
|
commit_sha = TriggerService.getCommitSHA(build_info.trigger_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $.extend(build_info, {
|
return $.extend(build_info, {
|
||||||
|
|
|
@ -33,7 +33,7 @@ angular.module('quay').directive('triggeredBuildDescription', function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (build.trigger && build.trigger.build_source && triggerMetadata.commit_sha) {
|
if (build.trigger && build.trigger.build_source && TriggerService.getCommitSHA(triggerMetadata)) {
|
||||||
$scope.infoDisplay = 'commitsha';
|
$scope.infoDisplay = 'commitsha';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,4 +43,4 @@ angular.module('quay').directive('triggeredBuildDescription', function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return directiveDefinitionObject;
|
return directiveDefinitionObject;
|
||||||
});
|
});
|
||||||
|
|
|
@ -252,6 +252,10 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
|
||||||
return desc;
|
return desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
triggerService.getCommitSHA = function(metadata) {
|
||||||
|
return metadata.commit || metadata.commit_sha;
|
||||||
|
};
|
||||||
|
|
||||||
triggerService.getMetadata = function(name) {
|
triggerService.getMetadata = function(name) {
|
||||||
return triggerTypes[name];
|
return triggerTypes[name];
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
Reference in a new issue