Merge pull request #140 from coreos-inc/eventinfo
Add more build information to the events and have better messaging
This commit is contained in:
commit
82287926ab
9 changed files with 89 additions and 30 deletions
|
@ -60,12 +60,13 @@ def start_build(repository, prepared_build, pull_robot_name=None):
|
|||
if prepared_build.trigger:
|
||||
event_log_metadata['trigger_id'] = prepared_build.trigger.uuid
|
||||
event_log_metadata['trigger_kind'] = prepared_build.trigger.service.name
|
||||
event_log_metadata['trigger_metadata'] = prepared_build.metadata or {}
|
||||
|
||||
model.log_action('build_dockerfile', repository.namespace_user.username, ip=request.remote_addr,
|
||||
metadata=event_log_metadata, repository=repository)
|
||||
|
||||
spawn_notification(repository, 'build_queued', event_log_metadata,
|
||||
subpage='build?current=%s' % build_request.uuid,
|
||||
subpage='build/%s' % build_request.uuid,
|
||||
pathargs=['build', build_request.uuid])
|
||||
|
||||
return build_request
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import logging
|
||||
import time
|
||||
|
||||
from datetime import datetime
|
||||
from notificationhelper import build_event_data
|
||||
from util.jinjautil import get_template_env
|
||||
|
||||
|
@ -76,6 +78,12 @@ class RepoPushEvent(NotificationEvent):
|
|||
})
|
||||
|
||||
|
||||
def _build_summary(event_data):
|
||||
""" Returns a summary string for the build data found in the event data block. """
|
||||
summary = 'for repository %s [%s]' % (event_data['repository'], event_data['build_id'][0:7])
|
||||
return summary
|
||||
|
||||
|
||||
class BuildQueueEvent(NotificationEvent):
|
||||
@classmethod
|
||||
def event_name(cls):
|
||||
|
@ -92,16 +100,27 @@ class BuildQueueEvent(NotificationEvent):
|
|||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
'trigger_id': '1245634',
|
||||
'trigger_kind': 'GitHub',
|
||||
'trigger_metadata': {
|
||||
"default_branch": "master",
|
||||
"ref": "refs/heads/somebranch",
|
||||
"commit_sha": "42d4a62c53350993ea41069e9f2cfdefb0df097d"
|
||||
"commit": "42d4a62c53350993ea41069e9f2cfdefb0df097d",
|
||||
"commit_info": {
|
||||
'url': 'http://path/to/the/commit',
|
||||
'message': 'Some commit message',
|
||||
'date': time.mktime(datetime.now().timetuple()),
|
||||
'author': {
|
||||
'username': 'fakeauthor',
|
||||
'url': 'http://path/to/fake/author/in/scm',
|
||||
'avatar_url': 'http://www.gravatar.com/avatar/fakehash'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, subpage='/build?current=%s' % build_uuid)
|
||||
}, subpage='/build/%s' % build_uuid)
|
||||
|
||||
def get_summary(self, event_data, notification_data):
|
||||
return 'Build queued for repository %s' % (event_data['repository'])
|
||||
return 'Build queued ' + _build_summary(event_data)
|
||||
|
||||
|
||||
class BuildStartEvent(NotificationEvent):
|
||||
|
@ -119,16 +138,17 @@ class BuildStartEvent(NotificationEvent):
|
|||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
'trigger_id': '1245634',
|
||||
'trigger_kind': 'GitHub',
|
||||
'trigger_metadata': {
|
||||
"default_branch": "master",
|
||||
"ref": "refs/heads/somebranch",
|
||||
"commit_sha": "42d4a62c53350993ea41069e9f2cfdefb0df097d"
|
||||
"commit": "42d4a62c53350993ea41069e9f2cfdefb0df097d"
|
||||
}
|
||||
}, subpage='/build?current=%s' % build_uuid)
|
||||
}, subpage='/build/%s' % build_uuid)
|
||||
|
||||
def get_summary(self, event_data, notification_data):
|
||||
return 'Build started for repository %s' % (event_data['repository'])
|
||||
return 'Build started ' + _build_summary(event_data)
|
||||
|
||||
|
||||
class BuildSuccessEvent(NotificationEvent):
|
||||
|
@ -146,17 +166,18 @@ class BuildSuccessEvent(NotificationEvent):
|
|||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
'trigger_id': '1245634',
|
||||
'trigger_kind': 'GitHub',
|
||||
'trigger_metadata': {
|
||||
"default_branch": "master",
|
||||
"ref": "refs/heads/somebranch",
|
||||
"commit_sha": "42d4a62c53350993ea41069e9f2cfdefb0df097d"
|
||||
"commit": "42d4a62c53350993ea41069e9f2cfdefb0df097d"
|
||||
},
|
||||
'image_id': '1245657346'
|
||||
}, subpage='/build?current=%s' % build_uuid)
|
||||
}, subpage='/build/%s' % build_uuid)
|
||||
|
||||
def get_summary(self, event_data, notification_data):
|
||||
return 'Build succeeded for repository %s' % (event_data['repository'])
|
||||
return 'Build succeeded ' + _build_summary(event_data)
|
||||
|
||||
|
||||
class BuildFailureEvent(NotificationEvent):
|
||||
|
@ -176,13 +197,25 @@ class BuildFailureEvent(NotificationEvent):
|
|||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
'trigger_kind': 'GitHub',
|
||||
'error_message': 'This is a fake error message',
|
||||
'trigger_id': '1245634',
|
||||
'trigger_kind': 'GitHub',
|
||||
'trigger_metadata': {
|
||||
"default_branch": "master",
|
||||
"ref": "refs/heads/somebranch",
|
||||
"commit_sha": "42d4a62c53350993ea41069e9f2cfdefb0df097d"
|
||||
"commit": "42d4a62c53350993ea41069e9f2cfdefb0df097d",
|
||||
"commit_info": {
|
||||
'url': 'http://path/to/the/commit',
|
||||
'message': 'Some commit message',
|
||||
'date': time.mktime(datetime.now().timetuple()),
|
||||
'author': {
|
||||
'username': 'fakeauthor',
|
||||
'url': 'http://path/to/fake/author/in/scm',
|
||||
'avatar_url': 'http://www.gravatar.com/avatar/fakehash'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, subpage='/build?current=%s' % build_uuid)
|
||||
|
||||
def get_summary(self, event_data, notification_data):
|
||||
return 'Build failure for repository %s' % (event_data['repository'])
|
||||
return 'Build failure ' + _build_summary(event_data)
|
||||
|
||||
|
|
|
@ -328,8 +328,7 @@ class SlackAdjuster(HTMLParser):
|
|||
self.result.append('*')
|
||||
|
||||
if tag == 'img':
|
||||
self.result.append(self.get_attr(attrs, 'alt'))
|
||||
self.result.append(' ')
|
||||
self.result.append('')
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
if tag == 'a':
|
||||
|
|
Reference in a new issue