a73e852165297d95e3abef6b0e77e7fc80179fca
[releng/global-jjb.git] / shell / whitesource-unified-agent-cli.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 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 "---> whitesource-unified-agent-cli.sh"
12 # This script downloads wss-unified-agent-<version>.jar and uses it to perform
13 # a scan on the code whithin a repo based on the wss-unified-agent.config provided.
14
15 # DO NOT enable -u because $WSS_UNIFIED_AGENT_OPTIONS could be unbound.
16 # Ensure we fail the job if any steps fail.
17 set -xe -o pipefail
18 set -u
19 echo "---> whitesource-unified-agent-cli.sh"
20 jar_location="/tmp/wss-unified-agent-${WSS_UNIFIED_AGENT_VERSION}.jar"
21 wss_unified_agent_url="https://s3.amazonaws.com/unified-agent/wss-unified-agent-${WSS_UNIFIED_AGENT_VERSION}.jar"
22 wget -nv "${wss_unified_agent_url}" -O "${jar_location}"
23
24 echo "---> Running WhiteSource Unified Agent CLI ..."
25
26 # WSS_UNIFIED_AGENT_OPTIONS & JAVA_OPTS are expected to be unquoted
27 # shellcheck disable=SC2086
28 java ${JAVA_OPTS:-} -jar "${jar_location}" -c wss-unified-agent.config \
29     -product "${WSS_PRODUCT_NAME}" -project "${WSS_PROJECT_NAME}" \
30     -projectVersion "${GERRIT_BRANCH}" ${WSS_UNIFIED_AGENT_OPTIONS:-}
31
32 rm "${jar_location}"