Skip to content

Commit c1f3b1f

Browse files
committed
[CI] BlackDuck scan startup fix
This change removes the NGCI module previously used for running BlackDuck scans. NGCI relied on a Gerrit user token for cloning BlackDuck, which was subject to periodic rotation and caused recurring CI failures. Instead, the scan is now executed manually via a custom script using an SSH-based access to Gerrit. This approach improves reliability, simplifies debugging, and provides clearer logs. Issue: HPCINFRA-3508 Signed-off-by: Viacheslav Login <[email protected]>
1 parent 19accb5 commit c1f3b1f

File tree

3 files changed

+80
-15
lines changed

3 files changed

+80
-15
lines changed

.ci/blackduck_source.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash -Exel
2+
3+
topdir=$(git rev-parse --show-toplevel)
4+
cd "$topdir"
5+
6+
# Check if the variables and pipeline attributes are set
7+
[[ -z "${WORKSPACE}" ]] && { echo "Error: WORKSPACE variable is not set"; exit 1; }
8+
[[ -z "$BLACKDUCK_API_TOKEN" ]] && { echo "Error: BLACKDUCK_API_TOKEN variable is not set"; exit 1; }
9+
[[ ! -d "${WORKSPACE}/logs" ]] && mkdir -p "${WORKSPACE}/logs"
10+
11+
# Create valid JSON for further authentication in BlackDuck server
12+
json=$(jq -n \
13+
--arg token "$BLACKDUCK_API_TOKEN" \
14+
'{"blackduck.url": "https://blackduck.mellanox.com/", "blackduck.api.token": $token }')
15+
16+
export SPRING_APPLICATION_JSON="$json"
17+
export PROJECT_NAME=LibVMA
18+
export PROJECT_VERSION="$sha1"
19+
export PROJECT_SRC_PATH="$topdir"/src/
20+
21+
echo "Running BlackDuck (SRC) on $name"
22+
echo "CONFIG:"
23+
echo " NAME: ${PROJECT_NAME}"
24+
echo " VERSION: ${PROJECT_VERSION}"
25+
echo " SRC_PATH: ${PROJECT_SRC_PATH}"
26+
27+
# clone BlackDuck
28+
[[ -d /tmp/blackduck ]] && rm -rf /tmp/blackduck
29+
[[ -d ~/.ssh/ ]] || mkdir -p ~/.ssh/
30+
chmod 600 "${GERRIT_SSH_KEY}"
31+
ssh-keyscan -p 12023 -H git-nbu.nvidia.com >> ~/.ssh/known_hosts
32+
git clone -c core.sshCommand="ssh -i ${GERRIT_SSH_KEY} -l swx-jenkins2-svc" -b master --single-branch --depth=1 ssh://git-nbu.nvidia.com:12023/DevOps/Tools/blackduck /tmp/blackduck
33+
cd /tmp/blackduck
34+
35+
# disable check errors
36+
set +e
37+
timeout 3600 ./run_bd_scan.sh
38+
exit_code=$?
39+
# enable back
40+
set -e
41+
42+
# copy run log to a place that jenkins job will archive it
43+
REPORT_NAME="BlackDuck_source_${PROJECT_NAME}_${PROJECT_VERSION}"
44+
cat "log/${PROJECT_NAME}_${PROJECT_VERSION}"*.log > "${WORKSPACE}/logs/${REPORT_NAME}.log" || true
45+
cat "log/${PROJECT_NAME}_${PROJECT_VERSION}"*.log || true
46+
47+
if [ "$exit_code" == "0" ]; then
48+
cp -v /tmp/blackduck/report/*.pdf "${WORKSPACE}/logs/${REPORT_NAME}.pdf"
49+
fi
50+
51+
exit $exit_code

.ci/dockerfiles/Dockerfile.rhel8.6

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ARG HARBOR_URL=nbu-harbor.gtm.nvidia.com
2+
ARG ARCH=x86_64
3+
FROM $HARBOR_URL/hpcx/x86_64/rhel8.6/core:latest
4+
ARG WEBREPO_URL=webrepo.gtm.nvidia.com
5+
6+
RUN sed -i "s/webrepo/${WEBREPO_URL}/" /etc/yum.repos.d/* && \
7+
sed -i 's/mirrorlist/#mirrorlist/;s!#baseurl=http://mirror.centos.org!baseurl=http://vault.centos.org!' /etc/yum.repos.d/* && \
8+
echo "[mlnx-opt]" > /etc/yum.repos.d/mlnx-opt.repo && \
9+
echo "name=RHEL 8.6 mirror" >> /etc/yum.repos.d/mlnx-opt.repo && \
10+
echo "baseurl=http://${WEBREPO_URL}/RH/optional/8.6/x86_64/" >> /etc/yum.repos.d/mlnx-opt.repo && \
11+
echo "enabled=1" >> /etc/yum.repos.d/mlnx-opt.repo && \
12+
echo "gpgcheck=0" >> /etc/yum.repos.d/mlnx-opt.repo && \
13+
yum makecache
14+
15+
RUN yum install --allowerasing -y \
16+
java-11-openjdk jq git && \
17+
yum clean all && \
18+
rm -rf /var/cache/yum

.ci/matrix_job.yaml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ kubernetes:
1616

1717
credentials:
1818
- {credentialsId: 'mellanox_github_credentials', usernameVariable: 'MELLANOX_GH_USER', passwordVariable: 'MELLANOX_GH_TOKEN'}
19+
- {credentialsId: 'swx-jenkins2-svc-gerrit-ssh-key', keyFileVariable: 'GERRIT_SSH_KEY', type: 'sshUserPrivateKey'}
1920

2021
volumes:
2122
- {mountPath: /hpc/local/bin, hostPath: /hpc/local/bin}
@@ -36,7 +37,7 @@ runs_on_dockers:
3637
- {name: 'sl15sp2-mofed-x86_64', url: 'harbor.mellanox.com/swx-infra/x86_64/sles15sp2/builder:mofed-5.2-2.2.0.0', category: 'base', arch: 'x86_64'}
3738
- {name: 'fc31-mofed-x86_64', url: 'harbor.mellanox.com/swx-infra/x86_64/fedora31/builder:mofed-5.1-1.0.7.0', category: 'base', arch: 'x86_64'}
3839
- {name: 'toolbox', url: 'harbor.mellanox.com/hpcx/x86_64/rhel8.3/builder:inbox', category: 'tool', arch: 'x86_64'}
39-
- {name: 'blackduck', url: 'harbor.mellanox.com/toolbox/ngci-centos:7.9.2009.2', category: 'tool', arch: 'x86_64'}
40+
- {name: 'blackduck', file: '.ci/dockerfiles/Dockerfile.rhel8.6', category: 'tool', arch: 'x86_64', tag: '20250422', uri: 'sockperf/$arch/$name/bduck', build_args: '--no-cache'}
4041
- {name: 'header-check', url: 'harbor.mellanox.com/toolbox/header_check:0.0.51', category: 'tool', arch: 'x86_64', tag: '0.0.51'}
4142

4243
runs_on_agents:
@@ -241,20 +242,15 @@ steps:
241242
- "{name: 'blackduck', category:'tool', variant:1}"
242243
agentSelector:
243244
- "{nodeLabel: 'skip-agent'}"
244-
shell: action
245-
module: ngci
246-
run: NGCIBlackDuckScan
247-
args:
248-
projectName: "sockperf"
249-
projectVersion: "0.1.0"
250-
projectSrcPath: "src"
251-
attachArtifact: true
252-
reportName: "BlackDuck report"
253-
scanMode: "source"
254-
skipDockerDaemonCheck: true
255-
credentialsId: "swx-jenkins3-svc_git-nbu_token"
256-
env:
257-
SPRING_APPLICATION_JSON: '{"blackduck.url":"https://blackduck.mellanox.com/","blackduck.api.token":"ODMwOWYwMzEtODA2ZC00MzBjLWI1ZDEtNmFiMjBkYzQzMzkwOjNmNjExN2M1LWE2ZmEtNDZlYS1hZjRiLTZlNDgwNjAwOTVjNw=="}'
245+
run: |
246+
# TODO: Hide secret under Jenkins credentials
247+
export BLACKDUCK_API_TOKEN="ODMwOWYwMzEtODA2ZC00MzBjLWI1ZDEtNmFiMjBkYzQzMzkwOjNmNjExN2M1LWE2ZmEtNDZlYS1hZjRiLTZlNDgwNjAwOTVjNw=="
248+
# WA for possible CI-Demo bug: HPCINFRA-1614
249+
if ${do_blackduck} ; then
250+
.ci/blackduck_source.sh
251+
fi
252+
archiveArtifacts: 'logs/'
253+
credentialsId: "swx-jenkins2-svc-gerrit-ssh-key"
258254

259255
pipeline_start:
260256
run: |

0 commit comments

Comments
 (0)