Jenkins: Add timestamps wrapper

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: Idfbf9ea149d664b5451b3a938fcc4e5d4e601485
diff --git a/jenkins/build-config.jpl b/jenkins/build-config.jpl
index f5dc3e9..3ce8acd 100644
--- a/jenkins/build-config.jpl
+++ b/jenkins/build-config.jpl
@@ -20,69 +20,27 @@
   return cause
 }
 
-node(nodeLabel) {
-  stage("Init") {
-    cleanWs()
-    dir("trusted-firmware-m") {
-      checkout(
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: '$GERRIT_BRANCH']],
-          extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
-          userRemoteConfigs: [[
-            credentialsId: 'GIT_SSH_KEY',
-            refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
-          ]]
-        ])
-    }
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
-    }
-    dir("mbedtls") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: 'refs/tags/$MBEDTLS_VERSION',
-            url: params.MBEDTLS_URL
-          ]]
-        ]
-      )
-    }
-    dir("mcuboot") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: '$MCUBOOT_REFSPEC',
-            url: params.MCUBOOT_URL
-          ]]
-        ]
-      )
-    }
-    dir("tf-m-tests") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: '$TFM_TESTS_REFSPEC',
-            url: params.TFM_TESTS_URL
-          ]]
-        ]
-      )
-    }
-    if (env.PSA_API_SUITE != "") {
-      dir("psa-arch-tests") {
+timestamps {
+  node(nodeLabel) {
+    stage("Init") {
+      cleanWs()
+      dir("trusted-firmware-m") {
+        checkout(
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: '$GERRIT_BRANCH']],
+            extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
+            userRemoteConfigs: [[
+              credentialsId: 'GIT_SSH_KEY',
+              refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
+            ]]
+          ])
+      }
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
+      dir("mbedtls") {
         checkout(
           changelog: false,
           poll: false,
@@ -90,45 +48,89 @@
             $class: 'GitSCM',
             branches: [[name: 'FETCH_HEAD']],
             userRemoteConfigs: [[
-              refspec: '$PSA_ARCH_TESTS_VERSION',
-              url: params.PSA_ARCH_TESTS_URL
+              refspec: 'refs/tags/$MBEDTLS_VERSION',
+              url: params.MBEDTLS_URL
             ]]
           ]
         )
       }
-    }
-  }
-  try {
-    verify = 1
-    stage("Build") {
-      sh "tf-m-ci-scripts/run-build.sh"
-    }
-    stage("Post") {
-      archiveArtifacts 'trusted-firmware-m/build/bin/**'
-      archiveArtifacts 'trusted-firmware-m/build/install/interface/**'
-      def upstreamProject = getUpstreamJob()[0].upstreamProject
-      if (upstreamProject == "tf-m-build-and-test") {
-        archiveArtifacts 'trusted-firmware-m/build/generated/**'
+      dir("mcuboot") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: '$MCUBOOT_REFSPEC',
+              url: params.MCUBOOT_URL
+            ]]
+          ]
+        )
       }
-      if (env.SQUAD_CONFIGURATIONS != ""){
-        //Creating a folder to store memory footprint artifacts and launching the memory footprint script.
-        sh "mkdir tf-m-ci-scripts/Memory_footprint/"
-        withCredentials([string(credentialsId: 'QA_REPORTS_TOKEN', variable: 'TOKEN')]) {
-          sh(script: "python3 tf-m-ci-scripts/memory_footprint.py ${env.WORKSPACE}/trusted-firmware-m/ ${env.CONFIG_NAME} \'${env.SQUAD_CONFIGURATIONS}\' ${TOKEN}", returnStdout: true)
-        }
-        if (fileExists('tf-m-ci-scripts/Memory_footprint/filesize.json')) {
-          archiveArtifacts 'tf-m-ci-scripts/Memory_footprint/filesize.json'
+      dir("tf-m-tests") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: '$TFM_TESTS_REFSPEC',
+              url: params.TFM_TESTS_URL
+            ]]
+          ]
+        )
+      }
+      if (env.PSA_API_SUITE != "") {
+        dir("psa-arch-tests") {
+          checkout(
+            changelog: false,
+            poll: false,
+            scm: [
+              $class: 'GitSCM',
+              branches: [[name: 'FETCH_HEAD']],
+              userRemoteConfigs: [[
+                refspec: '$PSA_ARCH_TESTS_VERSION',
+                url: params.PSA_ARCH_TESTS_URL
+              ]]
+            ]
+          )
         }
       }
     }
-  } catch (Exception e) {
-    manager.buildFailure()
-    verify = -1
-  } finally {
-    g = new Gerrit()
-    g.verifyStatusInWorkspace(verify, env.CONFIG_NAME, 'build')
-    def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
-    //g.commentInWorkspace("Build configuration ${env.CONFIG_NAME} ${buildStatus}: ${env.RUN_DISPLAY_URL}")
-    cleanWs()
+    try {
+      verify = 1
+      stage("Build") {
+        sh "tf-m-ci-scripts/run-build.sh"
+      }
+      stage("Post") {
+        archiveArtifacts 'trusted-firmware-m/build/bin/**'
+        archiveArtifacts 'trusted-firmware-m/build/install/interface/**'
+        def upstreamProject = getUpstreamJob()[0].upstreamProject
+        if (upstreamProject == "tf-m-build-and-test") {
+          archiveArtifacts 'trusted-firmware-m/build/generated/**'
+        }
+        if (env.SQUAD_CONFIGURATIONS != ""){
+          //Creating a folder to store memory footprint artifacts and launching the memory footprint script.
+          sh "mkdir tf-m-ci-scripts/Memory_footprint/"
+          withCredentials([string(credentialsId: 'QA_REPORTS_TOKEN', variable: 'TOKEN')]) {
+            sh(script: "python3 tf-m-ci-scripts/memory_footprint.py ${env.WORKSPACE}/trusted-firmware-m/ ${env.CONFIG_NAME} \'${env.SQUAD_CONFIGURATIONS}\' ${TOKEN}", returnStdout: true)
+          }
+          if (fileExists('tf-m-ci-scripts/Memory_footprint/filesize.json')) {
+            archiveArtifacts 'tf-m-ci-scripts/Memory_footprint/filesize.json'
+          }
+        }
+      }
+    } catch (Exception e) {
+      manager.buildFailure()
+      verify = -1
+    } finally {
+      g = new Gerrit()
+      g.verifyStatusInWorkspace(verify, env.CONFIG_NAME, 'build')
+      def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
+      //g.commentInWorkspace("Build configuration ${env.CONFIG_NAME} ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+      cleanWs()
+    }
   }
 }
diff --git a/jenkins/build-docs.jpl b/jenkins/build-docs.jpl
index 38b207f..a559eb8 100644
--- a/jenkins/build-docs.jpl
+++ b/jenkins/build-docs.jpl
@@ -9,84 +9,86 @@
 @Library('trustedfirmware') _
 import org.trustedfirmware.Gerrit
 
-node("docker-amd64-tf-m-bionic") {
-  stage("Init") {
-    cleanWs()
-    dir("trusted-firmware-m") {
-      checkout(
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: '$GERRIT_BRANCH']],
-          extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
-          userRemoteConfigs: [[
-            credentialsId: 'GIT_SSH_KEY',
-            refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
-          ]]
-        ])
+timestamps {
+  node("docker-amd64-tf-m-bionic") {
+    stage("Init") {
+      cleanWs()
+      dir("trusted-firmware-m") {
+        checkout(
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: '$GERRIT_BRANCH']],
+            extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
+            userRemoteConfigs: [[
+              credentialsId: 'GIT_SSH_KEY',
+              refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
+            ]]
+          ])
+      }
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
+      dir("mbedtls") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: 'refs/tags/$MBEDTLS_VERSION',
+              url: params.MBEDTLS_URL
+            ]]
+          ]
+        )
+      }
+      dir("mcuboot") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: '$MCUBOOT_REFSPEC',
+              url: params.MCUBOOT_URL
+            ]]
+          ]
+        )
+      }
+      dir("tf-m-tests") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: '$TFM_TESTS_REFSPEC',
+              url: params.TFM_TESTS_URL
+            ]]
+          ]
+        )
+      }
     }
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+    try {
+      verify = 1
+      stage("Build") {
+        sh "tf-m-ci-scripts/build-docs.sh"
+      }
+      stage("Post") {
+        archiveArtifacts 'trusted-firmware-m/build/docs/**'
+      }
+    } catch (Exception e) {
+      manager.buildFailure()
+      verify = -1
+    } finally {
+      g = new Gerrit()
+      g.verifyStatusInWorkspace(verify, 'tf-m-build-docs', 'build')
+      def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
+      //g.commentInWorkspace("Build docs ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+      cleanWs()
     }
-    dir("mbedtls") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: 'refs/tags/$MBEDTLS_VERSION',
-            url: params.MBEDTLS_URL
-          ]]
-        ]
-      )
-    }
-    dir("mcuboot") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: '$MCUBOOT_REFSPEC',
-            url: params.MCUBOOT_URL
-          ]]
-        ]
-      )
-    }
-    dir("tf-m-tests") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: '$TFM_TESTS_REFSPEC',
-            url: params.TFM_TESTS_URL
-          ]]
-        ]
-      )
-    }
-  }
-  try {
-    verify = 1
-    stage("Build") {
-      sh "tf-m-ci-scripts/build-docs.sh"
-    }
-    stage("Post") {
-      archiveArtifacts 'trusted-firmware-m/build/docs/**'
-    }
-  } catch (Exception e) {
-    manager.buildFailure()
-    verify = -1
-  } finally {
-    g = new Gerrit()
-    g.verifyStatusInWorkspace(verify, 'tf-m-build-docs', 'build')
-    def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
-    //g.commentInWorkspace("Build docs ${buildStatus}: ${env.RUN_DISPLAY_URL}")
-    cleanWs()
   }
 }
diff --git a/jenkins/checkpatch.jpl b/jenkins/checkpatch.jpl
index 6dcedef..5e8637d 100644
--- a/jenkins/checkpatch.jpl
+++ b/jenkins/checkpatch.jpl
@@ -9,43 +9,45 @@
 @Library('trustedfirmware') _
 import org.trustedfirmware.Gerrit
 
-node("docker-amd64-tf-m-bionic") {
-  stage("Init") {
-    cleanWs()
-    dir("trusted-firmware-m") {
-      checkout(
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: '$GERRIT_BRANCH']],
-          extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
-          userRemoteConfigs: [[
-            credentialsId: 'GIT_SSH_KEY',
-            refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
-          ]]
-        ])
-    }
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
-    }
-  }
-  stage("Check") {
-    def verify = 1
-    try {
-      sh """
-cd trusted-firmware-m
-../tf-m-ci-scripts/run-checkpatch.sh -u
-../tf-m-ci-scripts/run-checkpatch.sh -r -l 1
-"""
-    } catch (Exception e) {
-      manager.buildFailure()
-      verify = -1
-    } finally {
-      g = new Gerrit()
-      g.verifyStatusInWorkspace(verify, 'checkpatch', 'static')
-      def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
-      //g.commentInWorkspace("Build checkpatch ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+timestamps {
+  node("docker-amd64-tf-m-bionic") {
+    stage("Init") {
       cleanWs()
+      dir("trusted-firmware-m") {
+        checkout(
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: '$GERRIT_BRANCH']],
+            extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
+            userRemoteConfigs: [[
+              credentialsId: 'GIT_SSH_KEY',
+              refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
+            ]]
+          ])
+      }
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
+    }
+    stage("Check") {
+      def verify = 1
+      try {
+        sh """
+  cd trusted-firmware-m
+  ../tf-m-ci-scripts/run-checkpatch.sh -u
+  ../tf-m-ci-scripts/run-checkpatch.sh -r -l 1
+  """
+      } catch (Exception e) {
+        manager.buildFailure()
+        verify = -1
+      } finally {
+        g = new Gerrit()
+        g.verifyStatusInWorkspace(verify, 'checkpatch', 'static')
+        def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
+        //g.commentInWorkspace("Build checkpatch ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+        cleanWs()
+      }
     }
   }
 }
diff --git a/jenkins/ci.jpl b/jenkins/ci.jpl
index 684a1cd..8772341 100644
--- a/jenkins/ci.jpl
+++ b/jenkins/ci.jpl
@@ -457,97 +457,99 @@
 def builds = [:]
 def results = [:]
 
-node("docker-amd64-tf-m-bionic") {
-  stage("Init") {
-    cleanWs()
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+timestamps {
+  node("docker-amd64-tf-m-bionic") {
+    stage("Init") {
+      cleanWs()
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
+    }
+    stage("Configs") {
+      // Populate configs
+      listConfigs('tf-m-ci-scripts', configs, env.FILTER_GROUP)
+      results['builds'] = [:]
+      results['lava_jobs'] = []
+      for (config in configs) {
+        builds[config] = buildConfig("tf-m-ci-scripts", config, env.FILTER_GROUP, results)
+      }
+      builds["docs"] = buildDocs(results)
     }
   }
-  stage("Configs") {
-    // Populate configs
-    listConfigs('tf-m-ci-scripts', configs, env.FILTER_GROUP)
-    results['builds'] = [:]
-    results['lava_jobs'] = []
-    for (config in configs) {
-      builds[config] = buildConfig("tf-m-ci-scripts", config, env.FILTER_GROUP, results)
-    }
-    builds["docs"] = buildDocs(results)
-  }
-}
 
-stage("Builds") {
-  def verify = 1
-  def success = true
-  try {
-    parallel(builds)
-  } catch (Exception e) {
-    print(e)
-    manager.buildFailure()
-    verify = -1
-    success = false
-  } finally {
-    print("Verifying status")
-    def failed_builds = filterFailedBuild(results['builds'])
-    emailNotification(success, 'build', failed_builds)
-    g = new Gerrit()
-    g.verifyStatus(verify, 'tf-m-build', 'build')
-    print("Building CSV")
-    generateBuildCsv(results['builds'])
-    writeSummary(results['builds'])
-  }
-}
-
-node("docker-amd64-tf-m-bionic") {
-  stage("Tests") {
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
-    }
-    def all_jobs = []
+  stage("Builds") {
+    def verify = 1
     def success = true
-    print("Wait for LAVA results here...")
     try {
-      all_jobs = submitJobsToList(results['lava_jobs'])
-      if (all_jobs.size() > 0) {
-        dir("tf-m-ci-scripts") {
-          withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
-            output = sh(script: """./lava_helper/lava_wait_jobs.py --job-ids ${all_jobs.join(",")} \
-  --lava-url ${env.LAVA_URL} --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} \
-  --artifacts-path lava_artifacts --lava-timeout 7200 \
-  """, returnStdout: true).trim()
-            showLinks(output)
-            archiveArtifacts artifacts: 'test_summary.*', allowEmptyArchive: true
-            archiveArtifacts artifacts: 'test_results.csv', allowEmptyArchive: true
-            g = new Gerrit()
-            def (boot_result, boot_output) = getResult(output, 'BOOT_RESULT: ')
-            if (boot_result) {
-              g.verifyStatus(boot_result, "lava_boot", "test")
-            }
-            def (test_result, test_output) = getResult(output, 'TEST_RESULT: ')
-            if (test_result) {
-              g.verifyStatus(test_result, "lava_test", "test")
-            }
-            if (boot_result.toInteger() < 1 || test_result.toInteger() < 1) {
-              error("Marking job as failed due to failed boots: ${boot_output} or tests: ${test_output}")
+      parallel(builds)
+    } catch (Exception e) {
+      print(e)
+      manager.buildFailure()
+      verify = -1
+      success = false
+    } finally {
+      print("Verifying status")
+      def failed_builds = filterFailedBuild(results['builds'])
+      emailNotification(success, 'build', failed_builds)
+      g = new Gerrit()
+      g.verifyStatus(verify, 'tf-m-build', 'build')
+      print("Building CSV")
+      generateBuildCsv(results['builds'])
+      writeSummary(results['builds'])
+    }
+  }
+
+  node("docker-amd64-tf-m-bionic") {
+    stage("Tests") {
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
+      def all_jobs = []
+      def success = true
+      print("Wait for LAVA results here...")
+      try {
+        all_jobs = submitJobsToList(results['lava_jobs'])
+        if (all_jobs.size() > 0) {
+          dir("tf-m-ci-scripts") {
+            withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
+              output = sh(script: """./lava_helper/lava_wait_jobs.py --job-ids ${all_jobs.join(",")} \
+    --lava-url ${env.LAVA_URL} --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} \
+    --artifacts-path lava_artifacts --lava-timeout 7200 \
+    """, returnStdout: true).trim()
+              showLinks(output)
+              archiveArtifacts artifacts: 'test_summary.*', allowEmptyArchive: true
+              archiveArtifacts artifacts: 'test_results.csv', allowEmptyArchive: true
+              g = new Gerrit()
+              def (boot_result, boot_output) = getResult(output, 'BOOT_RESULT: ')
+              if (boot_result) {
+                g.verifyStatus(boot_result, "lava_boot", "test")
+              }
+              def (test_result, test_output) = getResult(output, 'TEST_RESULT: ')
+              if (test_result) {
+                g.verifyStatus(test_result, "lava_test", "test")
+              }
+              if (boot_result.toInteger() < 1 || test_result.toInteger() < 1) {
+                error("Marking job as failed due to failed boots: ${boot_output} or tests: ${test_output}")
+              }
             }
           }
         }
+        else {
+          print("There were no LAVA jobs to test.")
+        }
       }
-      else {
-        print("There were no LAVA jobs to test.")
-      }
-    }
-    catch (Exception e) {
-      print("ERROR: ${e}")
-      success = false
-    } finally {
-      archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_artifacts/**', allowEmptyArchive: true
-      if (all_jobs.size() > 0) {
-        emailNotification(success, 'test', filterFailedTest(output))
-      }
-      cleanWs()
-      if (!success) {
-        error("There was an Error waiting for LAVA jobs")
+      catch (Exception e) {
+        print("ERROR: ${e}")
+        success = false
+      } finally {
+        archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_artifacts/**', allowEmptyArchive: true
+        if (all_jobs.size() > 0) {
+          emailNotification(success, 'test', filterFailedTest(output))
+        }
+        cleanWs()
+        if (!success) {
+          error("There was an Error waiting for LAVA jobs")
+        }
       }
     }
   }
diff --git a/jenkins/cppcheck.jpl b/jenkins/cppcheck.jpl
index 8419f19..b88c7f2 100644
--- a/jenkins/cppcheck.jpl
+++ b/jenkins/cppcheck.jpl
@@ -9,88 +9,90 @@
 @Library('trustedfirmware') _
 import org.trustedfirmware.Gerrit
 
-node("docker-amd64-tf-m-bionic") {
-  stage("Init") {
-    cleanWs()
-    dir("trusted-firmware-m") {
-      checkout(
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: '$GERRIT_BRANCH']],
-          extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
-          userRemoteConfigs: [[
-            credentialsId: 'GIT_SSH_KEY',
-            refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
-          ]]
-        ])
-    }
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
-    }
-    dir("mbedtls") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: 'refs/tags/$MBEDTLS_VERSION',
-            url: params.MBEDTLS_URL
-          ]]
-        ]
-      )
-    }
-    dir("mcuboot") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: '$MCUBOOT_REFSPEC',
-            url: params.MCUBOOT_URL
-          ]]
-        ]
-      )
-    }
-    dir("tf-m-tests") {
-      checkout(
-        changelog: false,
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: 'FETCH_HEAD']],
-          userRemoteConfigs: [[
-            refspec: '$TFM_TESTS_REFSPEC',
-            url: params.TFM_TESTS_URL
-          ]]
-        ]
-      )
-    }
-  }
-  stage("Check") {
-    def verify = 1
-    try {
-      sh """
-cd trusted-firmware-m
-export GIT_REF_ARG=""
-if [ ! -z "\$GERRIT_PATCHSET_REVISION" ] ; then
-  export GIT_REF_ARG="HEAD"
-fi
-../tf-m-ci-scripts/run-cppcheck.sh -r \$GIT_REF_ARG
-"""
-    } catch (Exception e) {
-      manager.buildFailure()
-      verify = -1
-    } finally {
-      g = new Gerrit()
-      g.verifyStatusInWorkspace(verify, 'cppcheck', 'static')
-      def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
-      //g.commentInWorkspace("Build cppcheck ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+timestamps {
+  node("docker-amd64-tf-m-bionic") {
+    stage("Init") {
       cleanWs()
+      dir("trusted-firmware-m") {
+        checkout(
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: '$GERRIT_BRANCH']],
+            extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
+            userRemoteConfigs: [[
+              credentialsId: 'GIT_SSH_KEY',
+              refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
+            ]]
+          ])
+      }
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
+      dir("mbedtls") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: 'refs/tags/$MBEDTLS_VERSION',
+              url: params.MBEDTLS_URL
+            ]]
+          ]
+        )
+      }
+      dir("mcuboot") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: '$MCUBOOT_REFSPEC',
+              url: params.MCUBOOT_URL
+            ]]
+          ]
+        )
+      }
+      dir("tf-m-tests") {
+        checkout(
+          changelog: false,
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: 'FETCH_HEAD']],
+            userRemoteConfigs: [[
+              refspec: '$TFM_TESTS_REFSPEC',
+              url: params.TFM_TESTS_URL
+            ]]
+          ]
+        )
+      }
+    }
+    stage("Check") {
+      def verify = 1
+      try {
+        sh """
+           cd trusted-firmware-m
+           export GIT_REF_ARG=""
+           if [ ! -z "\$GERRIT_PATCHSET_REVISION" ] ; then
+             export GIT_REF_ARG="HEAD"
+           fi
+           ../tf-m-ci-scripts/run-cppcheck.sh -r \$GIT_REF_ARG
+           """
+      } catch (Exception e) {
+        manager.buildFailure()
+        verify = -1
+      } finally {
+        g = new Gerrit()
+        g.verifyStatusInWorkspace(verify, 'cppcheck', 'static')
+        def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
+        //g.commentInWorkspace("Build cppcheck ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+        cleanWs()
+      }
     }
   }
 }
diff --git a/jenkins/lava-submit.jpl b/jenkins/lava-submit.jpl
index 9cd7571..cf4ae0d 100644
--- a/jenkins/lava-submit.jpl
+++ b/jenkins/lava-submit.jpl
@@ -30,44 +30,46 @@
   }
 }
 
-node("docker-amd64-tf-m-bionic") {
-  stage("Init") {
-    cleanWs()
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+timestamps {
+  node("docker-amd64-tf-m-bionic") {
+    stage("Init") {
+      cleanWs()
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
     }
-  }
-  stage("LAVA") {
-    def fvp_only_cmd = ""
-    def upstreamProject = getUpstreamJob()[0].upstreamProject
-    if (upstreamProject == "tf-m-build-and-test") {
-      fvp_only_cmd = "--fvp-only "
-      print("Run test cases only on FVP in per-patch.")
-    }
+    stage("LAVA") {
+      def fvp_only_cmd = ""
+      def upstreamProject = getUpstreamJob()[0].upstreamProject
+      if (upstreamProject == "tf-m-build-and-test") {
+        fvp_only_cmd = "--fvp-only "
+        print("Run test cases only on FVP in per-patch.")
+      }
 
-    withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
-      print("Generating LAVA jobs...")
-      def bl2_string = ""
-      def psa_string = ""
-      if (env.BL2.equals("True")) {
-        bl2_string = "--bl2"
-      }
-      // work around this string containing quotes?
-      if (env.PSA_API_SUITE != "") {
-        psa_string = "--psa-api-suite ${env.PSA_API_SUITE}"
-      }
-      try {
-        submitJobs(fvp_only_cmd, bl2_string, psa_string)
-      } catch (Exception ex) {
-        print("LAVA-Submit failed! Exception: ${ex}")
-        print("Try to submit again...")
-        submitJobs(fvp_only_cmd, bl2_string, psa_string)
-        currentBuild.setDescription(currentBuild.getDescription() + " Submitted twice!")
+      withCredentials([usernamePassword(credentialsId: env.LAVA_CREDENTIALS, passwordVariable: 'LAVA_TOKEN', usernameVariable: 'LAVA_USER')]) {
+        print("Generating LAVA jobs...")
+        def bl2_string = ""
+        def psa_string = ""
+        if (env.BL2.equals("True")) {
+          bl2_string = "--bl2"
+        }
+        // work around this string containing quotes?
+        if (env.PSA_API_SUITE != "") {
+          psa_string = "--psa-api-suite ${env.PSA_API_SUITE}"
+        }
+        try {
+          submitJobs(fvp_only_cmd, bl2_string, psa_string)
+        } catch (Exception ex) {
+          print("LAVA-Submit failed! Exception: ${ex}")
+          print("Try to submit again...")
+          submitJobs(fvp_only_cmd, bl2_string, psa_string)
+          currentBuild.setDescription(currentBuild.getDescription() + " Submitted twice!")
+        }
       }
     }
-  }
-  stage("Post") {
-    archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_jobs/**', allowEmptyArchive: true
-    cleanWs()
+    stage("Post") {
+      archiveArtifacts artifacts: 'tf-m-ci-scripts/lava_jobs/**', allowEmptyArchive: true
+      cleanWs()
+    }
   }
 }
diff --git a/jenkins/static-checks.jpl b/jenkins/static-checks.jpl
index f766024..4aacad1 100644
--- a/jenkins/static-checks.jpl
+++ b/jenkins/static-checks.jpl
@@ -9,42 +9,44 @@
 @Library('trustedfirmware') _
 import org.trustedfirmware.Gerrit
 
-node("docker-amd64-tf-m-bionic") {
-  stage("Init") {
-    cleanWs()
-    dir("trusted-firmware-m") {
-      checkout(
-        poll: false,
-        scm: [
-          $class: 'GitSCM',
-          branches: [[name: '$GERRIT_BRANCH']],
-          extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
-          userRemoteConfigs: [[
-            credentialsId: 'GIT_SSH_KEY',
-            refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
-          ]]
-        ])
-    }
-    dir("tf-m-ci-scripts") {
-      checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
-    }
-  }
-  stage("Check") {
-    def verify = 1
-    try {
-      sh """
-cd trusted-firmware-m
-IS_CONTINUOUS_INTEGRATION=1 ../tf-m-ci-scripts/run-static-checks.sh
-"""
-    } catch (Exception e) {
-      manager.buildFailure()
-      verify = -1
-    } finally {
-      g = new Gerrit()
-      g.verifyStatusInWorkspace(verify, 'static-checks', 'static')
-      def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
-      //g.commentInWorkspace("Build checkpatch ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+timestamps {
+  node("docker-amd64-tf-m-bionic") {
+    stage("Init") {
       cleanWs()
+      dir("trusted-firmware-m") {
+        checkout(
+          poll: false,
+          scm: [
+            $class: 'GitSCM',
+            branches: [[name: '$GERRIT_BRANCH']],
+            extensions: [[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']]],
+            userRemoteConfigs: [[
+              credentialsId: 'GIT_SSH_KEY',
+              refspec: '$GERRIT_REFSPEC', url: '$CODE_REPO'
+            ]]
+          ])
+      }
+      dir("tf-m-ci-scripts") {
+        checkout([$class: 'GitSCM', branches: [[name: '$CI_SCRIPTS_BRANCH']], userRemoteConfigs: [[credentialsId: 'GIT_SSH_KEY', url: '$CI_SCRIPTS_REPO']]])
+      }
+    }
+    stage("Check") {
+      def verify = 1
+      try {
+        sh """
+           cd trusted-firmware-m
+           IS_CONTINUOUS_INTEGRATION=1 ../tf-m-ci-scripts/run-static-checks.sh
+           """
+      } catch (Exception e) {
+        manager.buildFailure()
+        verify = -1
+      } finally {
+        g = new Gerrit()
+        g.verifyStatusInWorkspace(verify, 'static-checks', 'static')
+        def buildStatus = (verify == 1) ? 'Successful' : 'Failed'
+        //g.commentInWorkspace("Build checkpatch ${buildStatus}: ${env.RUN_DISPLAY_URL}")
+        cleanWs()
+      }
     }
   }
 }
diff --git a/jenkins/static.jpl b/jenkins/static.jpl
index 95537a3..a7fe36d 100644
--- a/jenkins/static.jpl
+++ b/jenkins/static.jpl
@@ -23,22 +23,24 @@
 
 def status = 1
 
-stage("Static Checks") {
-  def checks = [:]
-  checks["cppcheck"] = trigger("tf-m-cppcheck")
-  checks["checkpatch"] = trigger("tf-m-checkpatch")
-  checks["static-checks"] = trigger("tf-m-static-checks")
-  try {
-    parallel(checks)
-  } catch (Exception e) {
-    status = -1
-    echo "Failed static checks, continuing with build."
+timestamps {
+  stage("Static Checks") {
+    def checks = [:]
+    checks["cppcheck"] = trigger("tf-m-cppcheck")
+    checks["checkpatch"] = trigger("tf-m-checkpatch")
+    checks["static-checks"] = trigger("tf-m-static-checks")
+    try {
+      parallel(checks)
+    } catch (Exception e) {
+      status = -1
+      echo "Failed static checks, continuing with build."
+    }
   }
-}
-stage("Trigger Build") {
-  parallel(["build":trigger("tf-m-build-and-test")])
-  // If previously failed at static checks, mark this as a failure
-  if (status < 0 ) {
-    error("Failing due to failed static checks.")
+  stage("Trigger Build") {
+    parallel(["build":trigger("tf-m-build-and-test")])
+    // If previously failed at static checks, mark this as a failure
+    if (status < 0 ) {
+      error("Failing due to failed static checks.")
+    }
   }
 }