#1717 Why does getBuildTarget only return Nil
Closed: Fixed 4 years ago by tkopecek. Opened 4 years ago by dcantrel.

The documentation is not clear on the usage. Given a build (like an ID or an NVR), I want to use getBuildTarget to get the build target information for that build. No matter what I pass it, I am only getting Nil back. I have tried build ID, NVR as a string, and task ID. Nothing works.

Is there a better way to get the build target information of a known build using the XML-RPC API?

Thanks.


It is not that easy to get from build to its build target. If we're speaking just about rpms, it can be done like this:

$ koji call getBuild resource-agents-4.4.0-1.fc31
{'build_id': 1403993,
 'cg_id': None,
 'cg_name': None,
 'completion_time': '2019-10-23 10:01:07.284660',
 'completion_ts': 1571824867.28466,
 'creation_event_id': 48098936,
 'creation_time': '2019-10-23 09:49:23.804888',
 'creation_ts': 1571824163.80489,
 'epoch': None,
 'extra': {'source': {'original_url': 'git+https://src.fedoraproject.org/rpms/resource-agents.git#70c234cd2fa03c6a97d971806b67cb580f9a782a'}},
 'id': 1403993,
 'name': 'resource-agents',
 'nvr': 'resource-agents-4.4.0-1.fc31',
 'owner_id': 3335,
 'owner_name': 'oalbrigt',
 'package_id': 7792,
 'package_name': 'resource-agents',
 'release': '1.fc31',
 'source': 'git+https://src.fedoraproject.org/rpms/resource-agents.git#70c234cd2fa03c6a97d971806b67cb580f9a782a',
 'start_time': '2019-10-23 09:49:23.804888',
 'start_ts': 1571824163.80489,
 'state': 1,
 'task_id': 38502663,
 'version': '4.4.0',
 'volume_id': 0,
 'volume_name': 'DEFAULT'}

# extract task_id and use it for getting task info + original request
$  koji call getTaskInfo request=True 38502663
{'arch': 'noarch',
 'awaited': None,
 'channel_id': 1,
 'completion_time': '2019-10-23 10:06:00.032856',
 'completion_ts': 1571825160.03286,
 'create_time': '2019-10-23 09:42:44.822085',
 'create_ts': 1571823764.82208,
 'host_id': 236,
 'id': 38502663,
 'label': None,
 'method': 'build',
 'owner': 3335,
 'parent': None,
 'priority': 20,
 'request': ['git+https://src.fedoraproject.org/rpms/resource-agents.git#70c234cd2fa03c6a97d971806b67cb580f9a782a',
             'f31-candidate',
             {}],
 'start_time': '2019-10-23 09:43:16.778424',
 'start_ts': 1571823796.77842,
 'state': 2,
 'waiting': False,
 'weight': 0.2}

# for build (rpm) tasks second argument in 'request' is name of the target, so you can get more info about target:
$ koji call getBuildTarget f31-candidate
{'build_tag': 6448,
 'build_tag_name': 'f31-build',
 'dest_tag': 6443,
 'dest_tag_name': 'f31-updates-candidate',
 'id': 3508,
 'name': 'f31-candidate'}

Metadata Update from @tkopecek:
- Custom field Size adjusted to None

4 years ago

Tomas,

Thanks for the info! This is exactly what I was looking for. If I have more questions, I may reach out to you directly for API clarification. This is good enough for me to go on now.

Metadata Update from @tkopecek:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata