CG metadata for koji task id

Related: https://pagure.io/koji/issue/215
This commit is contained in:
Tomas Kopecek 2023-01-17 13:26:17 +01:00
parent 6f068f1624
commit 5bbe106e69
2 changed files with 6 additions and 0 deletions

View file

@ -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:

View file

@ -6690,6 +6690,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)