From 3e2185784956b1f89f4f5127f330f56149b002eb Mon Sep 17 00:00:00 2001
From: Evgeny Sikachev <esikachev@mirantis.com>
Date: Fri, 24 Jun 2016 11:38:17 +0300
Subject: [PATCH] Added publisher script and job

Added job for daily publishing logs from slaves

Change-Id: Ie2733961928bb768003dd64cb30a5eb18c3b2302
---
 jenkins_job_builder/publisher.yaml | 25 +++++++++++++++++++++++++
 slave-scripts/publish-logs.sh      |  7 +++++++
 2 files changed, 32 insertions(+)
 create mode 100644 jenkins_job_builder/publisher.yaml
 create mode 100755 slave-scripts/publish-logs.sh

diff --git a/jenkins_job_builder/publisher.yaml b/jenkins_job_builder/publisher.yaml
new file mode 100644
index 00000000..bcbdb8a9
--- /dev/null
+++ b/jenkins_job_builder/publisher.yaml
@@ -0,0 +1,25 @@
+- job-template:
+    name: 'daily-log-publisher-{lab}'
+    defaults: global
+    builders:
+      - shell: |
+              git clone https://git.openstack.org/openstack/sahara-ci-config
+              ./$WORKSPACE/sahara-ci-config/slave-scripts/publish-logs.sh
+    triggers:
+      - timed: '50 5 * * *'
+    publishers:
+      - workspace-cleanup:
+          clean-if:
+            - success: true
+            - not-built: true
+            - aborted: true
+    node: 'lab-{lab}'
+
+
+- project:
+    name: publisher
+    lab:
+      - 42
+      - 43
+    jobs:
+     - 'daily-log-publisher-{lab}'
diff --git a/slave-scripts/publish-logs.sh b/slave-scripts/publish-logs.sh
new file mode 100755
index 00000000..26f17e97
--- /dev/null
+++ b/slave-scripts/publish-logs.sh
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+dir_name=$(date '+%d-%b-%Y')
+lab=$(echo $JOB_NAME | awk -F '-' '{ print $4 }')
+
+echo "Moving logs to the https://sahara-ci-reports.mirantis.com"
+rsync -e "ssh -i /home/jenkins/.ssh/rsync_key" -avz /opt/stack/logs/ ubuntu@172.18.180.78:/var/www/html/devstack/$lab/$dir_name