7e105c94ce6bae9c1129e0ba32510fbe2876bdd4
[releng/global-jjb.git] / shell / nexus-iq-python-cli.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2020 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 "---> nexus-iq-python-cli.sh"
12 # This script downloads the specified version of the nexus-iq-cli jar, uses it
13 # to analyze the Python project dependencies from the specified requirements file,
14 # then publishes the result to an LF server using the specified credentials.
15
16 # stop on error or unbound variable
17 set -eu
18 # do not print commands, credentials should not be logged
19 set +x
20 # check if tox established the prereqs for this analysis
21 if [[ ! -f $REQUIREMENTS_FILE ]]; then
22     echo "ERROR: failed to find file $REQUIREMENTS_FILE"
23     exit 1
24 fi
25 CLI_LOCATION="/tmp/nexus-iq-cli-${NEXUS_IQ_CLI_VERSION}.jar"
26 echo "INFO: downloading nexus-iq-cli version $NEXUS_IQ_CLI_VERSION"
27 wget -nv "https://download.sonatype.com/clm/scanner/nexus-iq-cli-${NEXUS_IQ_CLI_VERSION}.jar" -O "${CLI_LOCATION}"
28 echo "-a" > cli-auth.txt
29 echo "${NEXUS_IQ_USER}:${NEXUS_IQ_PASSWORD}" >> cli-auth.txt
30 echo "INFO: running nexus-iq-cli on project $NEXUS_IQ_PROJECT_NAME and file $REQUIREMENTS_FILE"
31 # result.json is a mystery
32 java -jar "${CLI_LOCATION}" @cli-auth.txt \
33     -s https://nexus-iq.wl.linuxfoundation.org -i "${NEXUS_IQ_PROJECT_NAME}" \
34     -t build -r result.json "${REQUIREMENTS_FILE}"
35 rm cli-auth.txt
36 rm "${CLI_LOCATION}"
37
38 echo "---> nexus-iq-python-cli.sh ends"