From 312e17971c0e30a2b03fdaa4fb380d0df67eabe2 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Mon, 15 Jan 2018 11:45:02 -0500 Subject: [PATCH] Add job to copy logs from a sandbox path to prod 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 --- jjb/copy-sandbox-logs.sh | 47 ++++++++++++++++++++++++++++++++++++++++ jjb/releng-jobs.yaml | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 jjb/copy-sandbox-logs.sh diff --git a/jjb/copy-sandbox-logs.sh b/jjb/copy-sandbox-logs.sh new file mode 100644 index 000000000..2cc2c82c6 --- /dev/null +++ b/jjb/copy-sandbox-logs.sh @@ -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 diff --git a/jjb/releng-jobs.yaml b/jjb/releng-jobs.yaml index 49997db4f..3e8cd1db3 100644 --- a/jjb/releng-jobs.yaml +++ b/jjb/releng-jobs.yaml @@ -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' @@ -117,6 +118,47 @@ 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' -- 2.36.6