Extend timeout for upgrade-mcp-release job

Tcp-qa loses connection to Jenkins if
it updates his docker images

Additionally added global err_msg variable
to retry decorator to prevent the
'referenced before assignment' error

Closes-Bug: PROD-36215
Change-Id: I31e9b47a3d330304a690cbf00e228c7e976c28d1
diff --git a/tcp_tests/managers/jenkins/client.py b/tcp_tests/managers/jenkins/client.py
index 063d400..79b248c 100644
--- a/tcp_tests/managers/jenkins/client.py
+++ b/tcp_tests/managers/jenkins/client.py
@@ -28,22 +28,25 @@
             :return: response
             :raise ConnectionError after several unsuccessful connections
             """
-            err = None
+            err_msg = None
             for count in range(max_count):
                 try:
                     return func(*args, **kwargs)
                 except Exception as err:
-                    print("Try {count}/{max_count} caught Exception: {err}. \
-                    \n... repeat after {secs} secs".
+                    err_msg = err
+                    print("Try {count}/{max_count} caught "
+                          "Exception in {fn}: {err}."
+                          "\n... repeat after {secs} secs".
                           format(err=err,
                                  count=count+1,
                                  max_count=max_count,
-                                 secs=sleep_before_retry))
+                                 secs=sleep_before_retry,
+                                 fn=func.__name__))
                 time.sleep(sleep_before_retry)
             print("Function failed in {total_time} seconds".format(
                 total_time=max_count*sleep_before_retry)
             )
-            raise err
+            raise err_msg
         return __retry
     return _retry
 
@@ -191,7 +194,11 @@
 
         def building():
             try:
-                status = not self.build_info(name, build_id)['building']
+                # Nested retry decorator. Need to wait >30 min
+                # During mcp-upgrade job the Jenkins can being upgrading
+                # and can be inaccessible for >20 min
+                status = not retry(max_count=30)(
+                    self.build_info)(name, build_id)['building']
             except ConnectionError:
                 status = False