Jenkins: Add timestamps wrapper

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: Idfbf9ea149d664b5451b3a938fcc4e5d4e601485
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()
+      }
     }
   }
 }