Fix: job-cost.sh no longer causes build failures 83/68083/1
authorEric Ball <eball@linuxfoundation.org>
Tue, 22 Jun 2021 21:51:19 +0000 (14:51 -0700)
committerEric Ball <eball@linuxfoundation.org>
Tue, 22 Jun 2021 21:54:25 +0000 (14:54 -0700)
job-cost.sh is gathering data, and if there is an error while doing
this, it should not cause the build to fail. If an error is detected,
it will be caught, a note is printing, and then the function will
simply return.

Issue: IT-22309
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
Change-Id: Ibba89d89223599e3ff9b077d036f5036d3252a68

vars/lfParallelCostCapture.groovy

index 9f60d84..dd1ae26 100644 (file)
 // limitations under the License.
 
 def call() {
-    sh(script: libraryResource('shell/job-cost.sh'))
-    cost_str = sh(script: "cat $WORKSPACE/archives/cost.csv | cut -d, -f6", returnStdout: true)
+    try {
+        sh(script: libraryResource('shell/job-cost.sh'))
+        cost_str = sh(script: "cat $WORKSPACE/archives/cost.csv | cut -d, -f6", returnStdout: true)
+    } catch(Exception e) {
+        // Failure in job-cost.sh should not affect the rest of the run.
+        println("Exception caught while running job-cost.sh.")
+        return
+    }
 
     lock("${BUILD_TAG}-stack-cost") {
         try {