Merge "Dumps container logs for xos-core tests"
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 b704369..6405553 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])
 
     }