From edb091b7b15489fc78b76b4345982c3ef13238de Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Jun 29 2021 01:10:28 +0000 Subject: Add task URL to watch task log JIRA: RHELCMP-5666 Signed-off-by: Haibo Lin --- diff --git a/pungi/wrappers/kojiwrapper.py b/pungi/wrappers/kojiwrapper.py index b501684..74e3195 100644 --- a/pungi/wrappers/kojiwrapper.py +++ b/pungi/wrappers/kojiwrapper.py @@ -564,6 +564,19 @@ class KojiWrapper(object): } def watch_task(self, task_id, log_file=None, max_retries=None): + """Watch and wait for a task to finish. + + :param int task_id: ID of koji task. + :param str log_file: Path to log file. + :param int max_retries: Max times to retry when error occurs, + no limits by default. + """ + if log_file: + task_url = os.path.join( + self.koji_module.config.weburl, "taskinfo?taskID=%d" % task_id + ) + with open(log_file, "a") as f: + f.write("Task URL: %s\n" % task_url) retcode, _ = self._wait_for_task( task_id, logfile=log_file, max_retries=max_retries )