- Add build notifications back in

- Fix spelling mistake
- Add the sha output as part of the build script
This commit is contained in:
Joseph Schorr 2015-02-03 13:01:42 -05:00
parent 361fb33574
commit 07e85324e9
3 changed files with 31 additions and 3 deletions

View file

@ -1 +1,2 @@
docker build -t quay.io/quay/quay:`git rev-parse --short HEAD` . docker build -t quay.io/quay/quay:`git rev-parse --short HEAD` .
echo quay.io/quay/quay:`git rev-parse --short HEAD`

View file

@ -74,11 +74,14 @@ class BuildComponent(BaseComponent):
yield trollius.From(self._set_status(ComponentStatus.BUILDING)) yield trollius.From(self._set_status(ComponentStatus.BUILDING))
# Send the notification that the build has started.
build_job.send_notification('build_start')
# Retrieve the job's buildpack. # Retrieve the job's buildpack.
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)
logger.debug('Retreiving build package: %s', buildpack_url) logger.debug('Retrieving build package: %s', buildpack_url)
buildpack = None buildpack = None
try: try:
buildpack = BuildPackage.from_url(buildpack_url) buildpack = BuildPackage.from_url(buildpack_url)
@ -262,6 +265,9 @@ class BuildComponent(BaseComponent):
result.result() result.result()
self._build_status.set_phase(BUILD_PHASE.COMPLETE) self._build_status.set_phase(BUILD_PHASE.COMPLETE)
trollius.async(self._build_finished(BuildJobResult.COMPLETE)) trollius.async(self._build_finished(BuildJobResult.COMPLETE))
# Send the notification that the build has completed successfully.
build_job.send_notification('build_success')
except ApplicationError as aex: except ApplicationError as aex:
worker_error = WorkerError(aex.error, aex.kwargs.get('base_error')) worker_error = WorkerError(aex.error, aex.kwargs.get('base_error'))
@ -269,6 +275,9 @@ class BuildComponent(BaseComponent):
self._build_status.set_error(worker_error.public_message(), worker_error.extra_data(), self._build_status.set_error(worker_error.public_message(), worker_error.extra_data(),
internal_error=worker_error.is_internal_error()) internal_error=worker_error.is_internal_error())
# Send the notification that the build has failed.
build_job.send_notification('build_failure', error_message=worker_error.public_message())
# Mark the build as completed. # Mark the build as completed.
if worker_error.is_internal_error(): if worker_error.is_internal_error():
trollius.async(self._build_finished(BuildJobResult.INCOMPLETE)) trollius.async(self._build_finished(BuildJobResult.INCOMPLETE))

View file

@ -1,7 +1,7 @@
import json import json
from cachetools import lru_cache from cachetools import lru_cache
from endpoints.notificationhelper import spawn_notification
from data import model from data import model
@ -21,6 +21,24 @@ class BuildJob(object):
'Could not parse build queue item config with ID %s' % self.job_details['build_uuid'] 'Could not parse build queue item config with ID %s' % self.job_details['build_uuid']
) )
def send_notification(self, kind, error_message=None):
tags = self.build_config.get('docker_tags', ['latest'])
event_data = {
'build_id': self.repo_build.uuid,
'build_name': self.repo_build.display_name,
'docker_tags': tags,
'trigger_id': self.repo_build.trigger.uuid,
'trigger_kind': self.repo_build.trigger.service.name
}
if error_message is not None:
event_data['error_message'] = message
spawn_notification(self.repo_build.repository, kind, event_data,
subpage='build?current=%s' % self.repo_build.uuid,
pathargs=['build', self.repo_build.uuid])
@lru_cache(maxsize=1) @lru_cache(maxsize=1)
def _load_repo_build(self): def _load_repo_build(self):
try: try: