#5509 include build target in fedmsg
Closed: Fixed 7 years ago Opened 7 years ago by bpeck.

Please consider adding the brew target to the fedmsg from koji so we can easily subscribe our ci builds on name and build target.


@ralph can you look at this? :-)

OK, @bpeck is specifically requesting here that we add the build target to the build.state.change messages coming from koji.

OK, it looks like the target is stored in the request which is associated with the task primarily associated with the build.

We could add a call to get that information ad stuff it in the message, but it will add some overhead.

>>> import time
>>> import koji
>>> s = koji.ClientSession('https://koji.fedoraproject.org/kojihub')
>>> start = time.time(); request = s.getTaskRequest(15926157); end = time.time(); print end - start
0.818114995956

That's a little less than a second (including https overhead that we get to avoid here). I think we can do this.

Here's a patch that should do it

diff --git a/roles/koji_hub/templates/fedmsg-koji-plugin.py b/roles/koji_hub/templates/fedmsg-koji-plugin.py
index 084d163..ce8b7fb 100644
--- a/roles/koji_hub/templates/fedmsg-koji-plugin.py
+++ b/roles/koji_hub/templates/fedmsg-koji-plugin.py
@@ -73,6 +73,11 @@ def get_message_body(topic, *args, **kws):
         msg['build_id'] = info.get('id', None)
         msg['task_id'] = info.get('task_id', None)

+        if msg['task_id']:
+            msg['request'] = kojihub.getTaskRequest(msg['task_id'])
+        else:
+            msg['request'] = None
+
         if 'owner_name' in info:
             msg['owner'] = info['owner_name']
         elif 'owner_id' in info:

We could look at applying that after the freeze is up in a few weeks (we just entered freeze last week).

Applied that patch. Thanks!

:snowman2:

@kevin changed the status to Fixed

7 years ago

Login to comment on this ticket.

Metadata