Dumps container logs for xos-core tests

Change-Id: I50af6d9585feeaa9e78c1b8bd77438ab45e11916
diff --git a/jjb/api-test.yaml b/jjb/api-test.yaml
index 8b14843..145a4fa 100644
--- a/jjb/api-test.yaml
+++ b/jjb/api-test.yaml
@@ -57,6 +57,11 @@
           default: '$GERRIT_PATCHSET_NUMBER'
           description: 'PatchSet number in Gerrit'
 
+      - bool:
+          name: ArchiveLogs
+          default: true
+          description: 'Archive all pod logs after test run'
+
     project-type: pipeline
     concurrent: true
 
diff --git a/jjb/pipeline/xos-core.groovy b/jjb/pipeline/xos-core.groovy
index e0681bd..39a2ea3 100644
--- a/jjb/pipeline/xos-core.groovy
+++ b/jjb/pipeline/xos-core.groovy
@@ -156,6 +156,19 @@
            """
       }
     }
+    stage ('Archive Artifacts') {
+      when { expression { return params.ArchiveLogs } }
+      steps {
+          sh '''
+           kubectl get pods --all-namespaces
+           ## get default pod logs
+           for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
+           do
+             kubectl logs \$pod> $WORKSPACE/\$pod.log;
+           done
+           '''
+      }
+    }
   }
   post {
     always {
@@ -186,6 +199,7 @@
             passThreshold: 100,
             reportFileName: 'RobotLogs/report*.html',
             unstableThreshold: 0]);
+         archiveArtifacts artifacts: '*.log'
          step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org, teo@opennetworking.org", sendToIndividuals: false])
 
     }