Using the cleanup state to collect the log

- always won't be called if the state is ABORTED or FAILURE.
- cleanup will be called as the final step after all state checking.
- Fixed lint error (duplicated key and trailing space)

Change-Id: I22961fd25bd8e4f087ab0ca4bd1db635987a44b7
diff --git a/jjb/cord-test/voltha.yaml b/jjb/cord-test/voltha.yaml
index 8145a78..ab6f339 100644
--- a/jjb/cord-test/voltha.yaml
+++ b/jjb/cord-test/voltha.yaml
@@ -224,7 +224,7 @@
           configurePod: true
           profile: 'Default'
 
-      # ONF DEMO OCP test job - voltha-master branch 
+      # ONF DEMO OCP test job - voltha-master branch
       - 'build_pod_test':
           testvm: 'menlo-demo-pod'
           config-pod: 'onf-demo-pod'
diff --git a/jjb/pipeline/voltha-system-test-bbsim.groovy b/jjb/pipeline/voltha-system-test-bbsim.groovy
index 68f96d7..78e6d3a 100644
--- a/jjb/pipeline/voltha-system-test-bbsim.groovy
+++ b/jjb/pipeline/voltha-system-test-bbsim.groovy
@@ -17,37 +17,37 @@
 // uses bbsim to simulate OLT/ONUs
 
 
-  def logKubernetes(prefix) {
-      sh """
-         set +e
-         cd kind-voltha/
-         cp install-minimal.log $WORKSPACE/${prefix}_instsall-minimal.log
-         kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
-         kubectl get nodes -o wide
-         kubectl get pods -o wide
-         kubectl get pods -n voltha -o wide
-         ## get default pod logs
-         for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
-         do
-           if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
-             kubectl logs \$pod onos> $WORKSPACE/${prefix}_\$pod.log;
-           else
-             kubectl logs \$pod> $WORKSPACE/${prefix}_\$pod.log;
-           fi
-         done
-         ## get voltha pod logs
-         for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
-         do
-           if [[ \$pod == *"-api-"* ]]; then
-             kubectl logs \$pod arouter -n voltha > $WORKSPACE/${prefix}_\$pod.log;
-           elif [[ \$pod == "bbsim-"* ]]; then
-             kubectl logs \$pod -n voltha -p > $WORKSPACE/${prefix}_\$pod.log;
-           else
-             kubectl logs \$pod -n voltha > $WORKSPACE/${prefix}_\$pod.log;
-           fi
-         done
-         """
-  }
+def logKubernetes(prefix) {
+    sh """
+        set +e
+        cd kind-voltha/
+        cp install-minimal.log $WORKSPACE/${prefix}_instsall-minimal.log
+        kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
+        kubectl get nodes -o wide
+        kubectl get pods -o wide
+        kubectl get pods -n voltha -o wide
+        ## get default pod logs
+        for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
+    do
+        if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
+            kubectl logs \$pod onos> $WORKSPACE/${prefix}_\$pod.log;
+        else
+            kubectl logs \$pod> $WORKSPACE/${prefix}_\$pod.log;
+    fi
+        done
+        ## get voltha pod logs
+        for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
+    do
+        if [[ \$pod == *"-api-"* ]]; then
+            kubectl logs \$pod arouter -n voltha > $WORKSPACE/${prefix}_\$pod.log;
+    elif [[ \$pod == "bbsim-"* ]]; then
+        kubectl logs \$pod -n voltha -p > $WORKSPACE/${prefix}_\$pod.log;
+        else
+            kubectl logs \$pod -n voltha > $WORKSPACE/${prefix}_\$pod.log;
+    fi
+        done
+        """
+}
 
 
 pipeline {
@@ -169,7 +169,7 @@
     aborted {
         logKubernetes('last')
     }
-    always {
+    cleanup {
 
          step([$class: 'RobotPublisher',
             disableArchiveOutput: false,
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index 0b0034c..53bb807 100644
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -241,7 +241,6 @@
                   Created from job-template {id} from ci-management/jjb/voltha-e2e.yaml <br />
                   Created by Andy Bavier, andy@opennetworking.org <br />
                   Copyright (c) 2019 Open Networking Foundation (ONF)
-    project-type: pipeline
     sandbox: true
     pipeline-script: 'voltha-physical-build-and-tests.groovy'
 
@@ -383,7 +382,6 @@
                   Created from job-template {id} from ci-management/jjb/voltha-e2e.yaml <br />
                   Created by Andy Bavier, andy@opennetworking.org <br />
                   Copyright (c) 2019 Open Networking Foundation (ONF)
-    project-type: pipeline
     sandbox: true
     pipeline-script: 'voltha-physical-build-and-tests.groovy'
 
@@ -526,7 +524,6 @@
                   Created from job-template {id} from ci-management/jjb/voltha-e2e.yaml <br />
                   Created by Andy Bavier, andy@opennetworking.org <br />
                   Copyright (c) 2019 Open Networking Foundation (ONF)
-    project-type: pipeline
     sandbox: true
     pipeline-script: 'voltha-physical-build-and-tests.groovy'