From: Matthew Watkins Date: Thu, 12 Jan 2023 17:04:19 +0000 (+0000) Subject: Fix: Update Nexus IQ script output to include Python dependencies X-Git-Tag: v0.83.5^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=42fbb1b57b7f344ef6193fb5391d787c5ade86ca;p=releng%2Fglobal-jjb.git Fix: Update Nexus IQ script output to include Python dependencies Script now downloads module dependencies into the target directory. Also, print a warning if the target variable is not set/populated and print the correct variable in the job output. Issue-ID: RELENG-4557 Signed-off-by: Matthew Watkins Change-Id: I1d4bbd752dd2282fc58c10636ad1aa228ad919a8 --- diff --git a/releasenotes/notes/nexus-iq-script-minor-update-cd81a3ee8fa5927f.yaml b/releasenotes/notes/nexus-iq-script-minor-update-cd81a3ee8fa5927f.yaml new file mode 100644 index 00000000..4bd74d0d --- /dev/null +++ b/releasenotes/notes/nexus-iq-script-minor-update-cd81a3ee8fa5927f.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + The Nexus IQ script was outputting the wrong variable during + execution, which could be misleading in the job console logs. Also + added a warning message if the NEXUS_TARGET_BUILD variable has not + been set/populated. Reports were not receiving module dependencies + so the script has been amended to download them into the target + directory, as per the Nexus IQ documentation. diff --git a/shell/nexus-iq-python-cli.sh b/shell/nexus-iq-python-cli.sh index 2e23f20c..037d1891 100644 --- a/shell/nexus-iq-python-cli.sh +++ b/shell/nexus-iq-python-cli.sh @@ -17,13 +17,26 @@ echo "---> nexus-iq-python-cli.sh" set -eu # do not print commands, credentials should not be logged set +x + +# shellcheck disable=SC1090 +. ~/lf-env.sh + +lf-activate-venv --python python3 --venv-file /tmp/.nexusiq virtualenv + CLI_LOCATION="/tmp/nexus-iq-cli-${NEXUS_IQ_CLI_VERSION}.jar" echo "INFO: downloading nexus-iq-cli version $NEXUS_IQ_CLI_VERSION" wget -nv "https://download.sonatype.com/clm/scanner/nexus-iq-cli-${NEXUS_IQ_CLI_VERSION}.jar" -O "${CLI_LOCATION}" echo "-a" > cli-auth.txt echo "${NEXUS_IQ_USER}:${NEXUS_IQ_PASSWORD}" >> cli-auth.txt -echo "INFO: running nexus-iq-cli on project $NEXUS_IQ_PROJECT_NAME and file $REQUIREMENTS_FILE" +if [ -z "${NEXUS_TARGET_BUILD}" ]; then + echo "WARN: NEXUS_TARGET_BUILD has not been set" +fi +echo "INFO: running nexus-iq-cli on project $NEXUS_IQ_PROJECT_NAME and target: ${NEXUS_TARGET_BUILD}" +echo "Downloading Python dependencies into target directory" +python3 -m pip download -r requirements.txt -d "${NEXUS_TARGET_BUILD}" # result.json is a mystery +# Do NOT double-quote ${NEXUS_TARGET_BUILD} below; causes breakage +# shellcheck disable=SC2086 java -jar "${CLI_LOCATION}" @cli-auth.txt \ -s https://nexus-iq.wl.linuxfoundation.org -i "${NEXUS_IQ_PROJECT_NAME}" \ -t build -r result.json ${NEXUS_TARGET_BUILD}