Try out the new koji postCommit fedmsg stuff in staging.
This commit is contained in:
parent
5078474ca2
commit
884b5bd845
1 changed files with 20 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
||||||
# Ralph Bean <rbean@redhat.com>
|
# Ralph Bean <rbean@redhat.com>
|
||||||
# Mike Bonnet <mikeb@redhat.com>
|
# Mike Bonnet <mikeb@redhat.com>
|
||||||
|
|
||||||
|
from koji.context import context
|
||||||
from koji.plugin import callbacks
|
from koji.plugin import callbacks
|
||||||
from koji.plugin import callback
|
from koji.plugin import callback
|
||||||
from koji.plugin import ignore_error
|
from koji.plugin import ignore_error
|
||||||
|
@ -130,7 +131,7 @@ def get_message_body(topic, *args, **kws):
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
@ignore_error
|
@ignore_error
|
||||||
def send_message(cbtype, *args, **kws):
|
def queue_message(cbtype, *args, **kws):
|
||||||
if cbtype.startswith('post'):
|
if cbtype.startswith('post'):
|
||||||
msgtype = cbtype[4:]
|
msgtype = cbtype[4:]
|
||||||
else:
|
else:
|
||||||
|
@ -178,4 +179,22 @@ def send_message(cbtype, *args, **kws):
|
||||||
|
|
||||||
body = scrub(body)
|
body = scrub(body)
|
||||||
|
|
||||||
|
{% if env != 'staging' %}
|
||||||
|
# Send the messages immediately.
|
||||||
fedmsg.publish(topic=topic, msg=body, modname='buildsys')
|
fedmsg.publish(topic=topic, msg=body, modname='buildsys')
|
||||||
|
{% else %}
|
||||||
|
# Queue the message for later.
|
||||||
|
# It will only get sent after postCommit is called.
|
||||||
|
messages = getattr(context, 'fedmsg_plugin_messages', [])
|
||||||
|
messages.append(dict(topic=topic, msg=body, modname='buildsys'))
|
||||||
|
context.fedmsg_plugin_messages = messages
|
||||||
|
|
||||||
|
|
||||||
|
# Meanwhile, postCommit actually sends messages.
|
||||||
|
@callback('postCommit')
|
||||||
|
@ignore_error
|
||||||
|
def send_messages(cbtype, *args, **kws):
|
||||||
|
messages = getattr(context, 'fedmsg_plugin_messages', [])
|
||||||
|
for message in messages:
|
||||||
|
fedmsg.publish(**message)
|
||||||
|
{% endif %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue