Make sure that jjb-cleanup.sh allows unbound vars
[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 set -x  # Trace commands for this script to make debugging easier.
17
18 ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
19 LOGS_SERVER="${LOGS_SERVER:-None}"
20
21 if [ "${LOGS_SERVER}" == 'None' ]
22 then
23     set +x # Disable trace since we no longer need it
24
25     echo "WARNING: Logging server not set"
26 else
27     NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
28     NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
29     BUILD_URL="${BUILD_URL}"
30
31     lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
32     lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
33
34     set +x  # Disable trace since we no longer need it.
35
36     echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
37 fi