From fad9f96b8e42a4bd60335bd8ebfa2ab1cc3682a4 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 06 2023 08:29:10 +0000 Subject: CG metadata for koji task id Related: https://pagure.io/koji/issue/215 --- diff --git a/docs/source/content_generator_metadata.rst b/docs/source/content_generator_metadata.rst index 2c8f19b..3fd5699 100644 --- a/docs/source/content_generator_metadata.rst +++ b/docs/source/content_generator_metadata.rst @@ -45,6 +45,7 @@ The build map contains the following entries: - owner: The owner of the build task in username format. This field is optional. - build_id: Reserved build ID. This field is optional. +- task_id: In case there is a corresponding task in koji (int/None) - extra: A map of extra metadata associated with the build, which must include at least one of: diff --git a/kojihub/kojihub.py b/kojihub/kojihub.py index ade8904..6d20cae 100644 --- a/kojihub/kojihub.py +++ b/kojihub/kojihub.py @@ -6689,6 +6689,11 @@ class CG_Importer(object): buildinfo['completion_time'] = \ datetime.datetime.fromtimestamp(float(metadata['build']['end_time'])).isoformat(' ') owner = metadata['build'].get('owner', None) + # get task id from OSBS or from standard place + if metadata['build'].get('task_id'): + buildinfo['task_id'] = int(metadata['build']['task_id']) + elif metadata['build'].get('extra', {}).get('container_koji_task_id'): + buildinfo['task_id'] = int(metadata['build']['extra']['container_koji_task_id']) if owner: if not isinstance(owner, str): raise koji.GenericError("Invalid owner format (expected username): %s" % owner)