Add job to copy logs from a sandbox path to prod 67/67167/3
authorThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 15 Jan 2018 16:45:02 +0000 (11:45 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 15 Jan 2018 17:17:28 +0000 (12:17 -0500)
As requested by the netvirt project to provide capabilities for
storing logs for a longer amount of time in cases where they need
to perform complex troubleshooting. This patch adds a job which
when given a log path will pull the logs from path on sandbox
and copy them to the releng system.

Change-Id: I96c8b8eb8d54c266ccab1c9bf19450b11d5bea69
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/copy-sandbox-logs.sh [new file with mode: 0644]
jjb/releng-jobs.yaml

diff --git a/jjb/copy-sandbox-logs.sh b/jjb/copy-sandbox-logs.sh
new file mode 100644 (file)
index 0000000..2cc2c82
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+# Allows folks to copy sandbox logs over to releng for longer storage
+#
+# In some cases folks would like to save sandbox logs for a longer period of
+# time in order to troubleshoot difficult tasks. This script can be used to
+# trigger Jenkins production to copy specific logs over for longer storage.
+#
+# This is triggered via Gerrit comment.
+# Usage: copy-logs: JOB_NAME/BUILD_NUMBER
+echo "---> copy-sandbox-logs.sh"
+
+build_path="$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'copy-logs:' | awk -F: '{print $2}' | tr -d '[:space:]')"
+fetch_url="https://logs.opendaylight.org/sandbox/vex-yul-odl-jenkins-2/$build_path"
+
+COPY_DIR="$WORKSPACE/archives"
+mkdir -p "$COPY_DIR"
+pushd "$COPY_DIR" || exit
+
+# Ensure that the repo_url has a trailing slash as wget needs it to work
+case "$fetch_url" in
+    */)
+        ;;
+    *)
+        fetch_url="$fetch_url/"
+        ;;
+esac
+
+echo "Fetching artifacts from $fetch_url..."
+wget -nv --recursive --execute robots=off --no-parent \
+    --no-host-directories --cut-dirs=2 --level=15 \
+    "$fetch_url"
+
+echo "Removing files that do not need to be cloned..."
+mapfile -t remove_files < <(find . -type f -name "*index.html*")
+for f in "${remove_files[@]}"; do
+    rm "$f"
+done
+popd || exit
index 49997db4f9f0ae9ff72be99b5d31f6d553acded3..3e8cd1db36fd0282755739a552cf8086be283a2d 100644 (file)
@@ -4,6 +4,7 @@
     jobs:
       - '{project-name}-ci-jobs'
       - builder-check-poms
+      - builder-copy-sandbox-logs
       - gerrit-tox-verify
       # OpenStack Related
       - 'builder-verify-image-protection'
           email-prefix: '[releng]'
       - lf-infra-publish
 
+- job-template:
+    name: builder-copy-sandbox-logs
+    node: centos7-builder-2c-8g
+
+    project-type: freestyle
+
+    properties:
+      - opendaylight-infra-properties:
+          build-days-to-keep: 1
+
+    parameters:
+      - opendaylight-infra-parameters:
+          os-cloud: ''
+          project: ''
+          branch: ''
+          refspec: ''
+          artifacts: ''
+
+    wrappers:
+      - opendaylight-infra-wrappers:
+          build-timeout: 10
+
+    triggers:
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on:
+            - comment-added-contains-event:
+                comment-contains-value: 'copy-logs:'
+          projects:
+            - project-compare-type: ANT
+              project-pattern: '**'
+              branches:
+                - branch-compare-type: ANT
+                  branch-pattern: '**'
+
+    builders:
+      - shell: !include-raw-escape: copy-sandbox-logs.sh
+
+    publishers:
+      - lf-infra-publish
+
 
 - job-template:
     name: 'builder-verify-image-protection'