Remove unused views
[releng/builder.git] / jjb / copy-sandbox-logs.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 # Allows folks to copy sandbox logs over to releng for longer storage
12 #
13 # In some cases folks would like to save sandbox logs for a longer period of
14 # time in order to troubleshoot difficult tasks. This script can be used to
15 # trigger Jenkins production to copy specific logs over for longer storage.
16 #
17 # This is triggered via Gerrit comment.
18 # Usage: copy-logs: JOB_NAME/BUILD_NUMBER
19 echo "---> copy-sandbox-logs.sh"
20
21 build_path="$(echo "$GERRIT_EVENT_COMMENT_TEXT" | grep 'copy-logs:' | awk -F: '{print $2}' | tr -d '[:space:]')"
22 fetch_url="https://logs.opendaylight.org/sandbox/vex-yul-odl-jenkins-2/$build_path"
23
24 COPY_DIR="$WORKSPACE/archives"
25 mkdir -p "$COPY_DIR"
26 pushd "$COPY_DIR" || exit
27
28 # Ensure that the repo_url has a trailing slash as wget needs it to work
29 case "$fetch_url" in
30     */)
31         ;;
32     *)
33         fetch_url="$fetch_url/"
34         ;;
35 esac
36
37 echo "Fetching artifacts from $fetch_url..."
38 wget -nv --recursive --execute robots=off --no-parent \
39     --no-host-directories --cut-dirs=2 --level=15 \
40     "$fetch_url"
41
42 echo "Removing files that do not need to be cloned..."
43 mapfile -t remove_files < <(find . -type f -name "*index.html*")
44 for f in "${remove_files[@]}"; do
45     rm "$f"
46 done
47 popd || exit