23660d7af5d88701f16e7b28bb9c283e86d8114a
[releng/global-jjb.git] / shell / logs-deploy.sh
1 #!/bin/bash -l
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 echo "---> logs-deploy.sh"
12
13 # Ensure we fail the job if any steps fail.
14 set -eu -o pipefail
15
16 if [[ -z $"${LOGS_SERVER:-}" ]]; then
17     echo "WARNING: Logging server not set"
18 else
19     nexus_url="${NEXUSPROXY:-$NEXUS_URL}"
20     nexus_path="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
21
22     # Handle multiple search extensions as separate values to '-p|--pattern'
23     set -f # Disable pathname expansion
24     search_exts=()
25     IFS=' ' read -r -a search_exts <<< "${ARCHIVE_ARTIFACTS:-}"
26     pattern_opts=()
27     for search_ext in "${search_exts[@]:-}";
28     do
29         pattern_opts+=("-p" "$search_ext")
30     done
31
32     lftools deploy archives "${pattern_opts[@]}" "$nexus_url" "$nexus_path" \
33             "$WORKSPACE"
34     set +f  # Enable pathname expansion
35     lftools deploy logs "$nexus_url" "$nexus_path" "${BUILD_URL:-}"
36
37     echo "Build logs: <a href=\"$LOGS_SERVER/$nexus_path\">$LOGS_SERVER/$nexus_path</a>"
38 fi