Fix: Update Nexus IQ script output to include Python dependencies 37/71137/12 v0.83.5
authorMatthew Watkins <mwatkins@linuxfoundation.org>
Thu, 12 Jan 2023 17:04:19 +0000 (17:04 +0000)
committerMatthew Watkins <mwatkins@linuxfoundation.org>
Mon, 23 Jan 2023 10:57:27 +0000 (10:57 +0000)
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 <mwatkins@linuxfoundation.org>
Change-Id: I1d4bbd752dd2282fc58c10636ad1aa228ad919a8

releasenotes/notes/nexus-iq-script-minor-update-cd81a3ee8fa5927f.yaml [new file with mode: 0644]
shell/nexus-iq-python-cli.sh

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 (file)
index 0000000..4bd74d0
--- /dev/null
@@ -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.
index 2e23f20..037d189 100644 (file)
@@ -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}