Add waiter to run_build method

Change-Id: Id2afcb0b79512883fdb0c66a2b069a89e7ac85ba
diff --git a/src/com/mirantis/system_qa/SharedPipeline.groovy b/src/com/mirantis/system_qa/SharedPipeline.groovy
index 0483965..53927f7 100644
--- a/src/com/mirantis/system_qa/SharedPipeline.groovy
+++ b/src/com/mirantis/system_qa/SharedPipeline.groovy
@@ -7,7 +7,7 @@
     def common = new com.mirantis.mk.Common()
     common.printMsg("Run shell command:\n" + cmd, "blue")
     def VENV_PATH='/home/jenkins/fuel-devops30'
-    script = """\
+    def script = """\
         set -ex;
         . ${VENV_PATH}/bin/activate;
         bash -c '${cmd.stripIndent()}'
@@ -20,18 +20,24 @@
     common.printMsg("Run shell command:\n" + cmd, "blue")
     def VENV_PATH='/home/jenkins/fuel-devops30'
     def stderr_path = "/tmp/${JOB_NAME}_${BUILD_NUMBER}_stderr.log"
-    script = """\
-        set +x;
-        echo 'activate python virtualenv ${VENV_PATH}';
-        . ${VENV_PATH}/bin/activate;
-        bash -c 'set -ex; set -ex; ${cmd.stripIndent()}' 2>${stderr_path}
+    def script = """#!/bin/bash
+        set +x
+        echo 'activate python virtualenv ${VENV_PATH}'
+        . ${VENV_PATH}/bin/activate
+        bash -c -e -x '${cmd.stripIndent()}' 2>${stderr_path}
     """
-    def result
     try {
-        return sh(script: script, returnStdout: returnStdout)
+        def stdout = sh(script: script, returnStdout: returnStdout)
+        def stderr = readFile("${stderr_path}")
+        def error_message = "\n<<<<<< STDERR: >>>>>>\n" + stderr
+        common.printMsg(error_message, "yellow")
+        common.printMsg("", "reset")
+        return stdout
     } catch (e) {
         def stderr = readFile("${stderr_path}")
         def error_message = e.message + "\n<<<<<< STDERR: >>>>>>\n" + stderr
+        common.printMsg(error_message, "red")
+        common.printMsg("", "reset")
         throw new Exception(error_message)
     } finally {
         sh(script: "rm ${stderr_path} || true")