Updated: collecting info in case of software upgrade jobs

Change-Id: I1bc091bba0f6399d7d5d81a56f36eecc543b57f2
diff --git a/jjb/pipeline/voltha/master/software-upgrades.groovy b/jjb/pipeline/voltha/master/software-upgrades.groovy
index 387cfe3..d57594e 100644
--- a/jjb/pipeline/voltha/master/software-upgrades.groovy
+++ b/jjb/pipeline/voltha/master/software-upgrades.groovy
@@ -112,14 +112,21 @@
         ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9
       """
       // collect pod details
-      sh """
-      kubectl get pods --all-namespaces -o wide > \$WORKSPACE/${name}/pods.txt || true
-      kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee \$WORKSPACE/${name}/pod-images.txt || true
-      kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee \$WORKSPACE/${name}/pod-imagesId.txt || true
-      """
+      get_pods_info("$WORKSPACE/${name}")
       helmTeardown(['infra', 'voltha'])
   }
 }
+def get_pods_info(dest) {
+  // collect pod details, this is here in case of failure
+  sh """
+  mkdir -p ${dest}
+  kubectl get pods --all-namespaces -o wide > ${dest}/pods.txt || true
+  kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee ${dest}/pod-images.txt || true
+  kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq | tee ${dest}/pod-imagesId.txt || true
+  kubectl describe pods --all-namespaces -l app.kubernetes.io/part-of=voltha > ${dest}/pods-describe.txt
+  helm ls --all-namespaces > ${dest}/helm-charts.txt
+  """
+}
 pipeline {
   /* no label, executor is determined by JJB */
   agent {
@@ -150,6 +157,12 @@
     }
   }
   post {
+    aborted {
+      get_pods_info("$WORKSPACE/failed")
+    }
+    failure {
+      get_pods_info("$WORKSPACE/failed")
+    }
     always {
       sh '''
       gzip $WORKSPACE/onos-app-upgrade/onos-voltha-combined.log || true
@@ -164,7 +177,7 @@
          passThreshold: 100,
          reportFileName: 'RobotLogs/*/report*.html',
          unstableThreshold: 0]);
-      archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz'
+      archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt'
     }
   }
 }