2e23f20cfef1ef1ebf7d5d957c03640774bbd1b6
[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 CLI_LOCATION="/tmp/nexus-iq-cli-${NEXUS_IQ_CLI_VERSION}.jar"
21 echo "INFO: downloading nexus-iq-cli version $NEXUS_IQ_CLI_VERSION"
22 wget -nv "https://download.sonatype.com/clm/scanner/nexus-iq-cli-${NEXUS_IQ_CLI_VERSION}.jar" -O "${CLI_LOCATION}"
23 echo "-a" > cli-auth.txt
24 echo "${NEXUS_IQ_USER}:${NEXUS_IQ_PASSWORD}" >> cli-auth.txt
25 echo "INFO: running nexus-iq-cli on project $NEXUS_IQ_PROJECT_NAME and file $REQUIREMENTS_FILE"
26 # result.json is a mystery
27 java -jar "${CLI_LOCATION}" @cli-auth.txt \
28     -s https://nexus-iq.wl.linuxfoundation.org -i "${NEXUS_IQ_PROJECT_NAME}" \
29     -t build -r result.json ${NEXUS_TARGET_BUILD}
30 rm cli-auth.txt
31 rm "${CLI_LOCATION}"
32
33 echo "---> nexus-iq-python-cli.sh ends"