Skip to content

Commit 6998786

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 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 4f151a7 commit 6998786

File tree

3 files changed

+78
-16
lines changed

3 files changed

+78
-16
lines changed

.ci/blackduck_source.sh

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

1818
credentials:
1919
- {credentialsId: 'mellanox_github_credentials', usernameVariable: 'MELLANOX_GH_USER', passwordVariable: 'MELLANOX_GH_TOKEN'}
20+
- {credentialsId: 'swx-jenkins2-svc-gerrit-ssh-key', keyFileVariable: 'GERRIT_SSH_KEY', type: 'sshUserPrivateKey'}
21+
- {credentialsId: 'blackduck_api_token', type: 'string', variable: 'BLACKDUCK_API_TOKEN'}
2022

2123
volumes:
2224
- {mountPath: /hpc/local/bin, hostPath: /hpc/local/bin}
@@ -37,7 +39,7 @@ runs_on_dockers:
3739
- {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'}
3840
- {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'}
3941
- {name: 'toolbox', url: 'harbor.mellanox.com/hpcx/x86_64/rhel8.3/builder:inbox', category: 'tool', arch: 'x86_64'}
40-
- {name: 'blackduck', url: 'harbor.mellanox.com/toolbox/ngci-centos:7.9.2009.2', category: 'tool', arch: 'x86_64'}
42+
- {name: 'blackduck', file: '.ci/dockerfiles/Dockerfile.rhel8.6', category: 'tool', arch: 'x86_64', tag: '20250422', uri: 'sockperf/$arch/$name/bduck', build_args: '--no-cache'}
4143
- {name: 'header-check', url: 'harbor.mellanox.com/toolbox/header_check:0.0.51', category: 'tool', arch: 'x86_64', tag: '0.0.51'}
4244

4345
runs_on_agents:
@@ -242,20 +244,15 @@ steps:
242244
- "{name: 'blackduck', category:'tool', variant:1}"
243245
agentSelector:
244246
- "{nodeLabel: 'skip-agent'}"
245-
shell: action
246-
module: ngci
247-
run: NGCIBlackDuckScan
248-
args:
249-
projectName: "sockperf"
250-
projectVersion: "0.1.0"
251-
projectSrcPath: "src"
252-
attachArtifact: true
253-
reportName: "BlackDuck report"
254-
scanMode: "source"
255-
skipDockerDaemonCheck: true
256-
credentialsId: "swx-jenkins3-svc_git-nbu_token"
257-
env:
258-
SPRING_APPLICATION_JSON: '{"blackduck.url":"https://blackduck.mellanox.com/","blackduck.api.token":"ODMwOWYwMzEtODA2ZC00MzBjLWI1ZDEtNmFiMjBkYzQzMzkwOjNmNjExN2M1LWE2ZmEtNDZlYS1hZjRiLTZlNDgwNjAwOTVjNw=="}'
247+
run: |
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:
254+
- "swx-jenkins2-svc-gerrit-ssh-key"
255+
- "blackduck_api_token"
259256

260257
pipeline_start:
261258
run: |
@@ -268,6 +265,6 @@ pipeline_stop:
268265
269266
failFast: false
270267

271-
timeout_minutes: 180
268+
timeout_minutes: 150
272269

273270
taskName: '${flags}/${name}/${axis_index}'

0 commit comments

Comments
 (0)