Skip to content

Commit 42aea06

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 21c6c94 commit 42aea06

File tree

3 files changed

+86
-15
lines changed

3 files changed

+86
-15
lines changed

.ci/blackduck_source.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
sudo -u swx-jenkins git clone -c core.sshCommand="ssh -i ~/.ssh/id_ed25519" -b master --single-branch --depth=1 ssh://git-nbu.nvidia.com:12023/DevOps/Tools/blackduck /tmp/blackduck
27+
cd /tmp/blackduck
28+
29+
# disable check errors
30+
set +e
31+
timeout 3600 ./run_bd_scan.sh
32+
exit_code=$?
33+
# enable back
34+
set -e
35+
36+
# copy run log to a place that jenkins job will archive it
37+
REPORT_NAME="BlackDuck_source_${PROJECT_NAME}_${PROJECT_VERSION}"
38+
cat "log/${PROJECT_NAME}_${PROJECT_VERSION}"*.log > "${WORKSPACE}/logs/${REPORT_NAME}.log" || true
39+
cat "log/${PROJECT_NAME}_${PROJECT_VERSION}"*.log || true
40+
41+
if [ "${exit_code}" == "0" ]; then
42+
cp -v /tmp/blackduck/report/*.pdf "${WORKSPACE}/logs/${REPORT_NAME}.pdf"
43+
fi
44+
45+
exit "${exit_code}"

.ci/dockerfiles/Dockerfile.rhel8.6

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
ARG _UID=6213
6+
ARG _GID=101
7+
ARG _LOGIN=swx-jenkins
8+
ARG _HOME=/var/home/$_LOGIN
9+
10+
RUN sed -i "s/webrepo/${WEBREPO_URL}/" /etc/yum.repos.d/* && \
11+
sed -i 's/mirrorlist/#mirrorlist/;s!#baseurl=http://mirror.centos.org!baseurl=http://vault.centos.org!' /etc/yum.repos.d/* && \
12+
echo "[mlnx-opt]" > /etc/yum.repos.d/mlnx-opt.repo && \
13+
echo "name=RHEL 8.6 mirror" >> /etc/yum.repos.d/mlnx-opt.repo && \
14+
echo "baseurl=http://${WEBREPO_URL}/RH/optional/8.6/x86_64/" >> /etc/yum.repos.d/mlnx-opt.repo && \
15+
echo "enabled=1" >> /etc/yum.repos.d/mlnx-opt.repo && \
16+
echo "gpgcheck=0" >> /etc/yum.repos.d/mlnx-opt.repo && \
17+
yum makecache
18+
19+
RUN echo "${_LOGIN} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
20+
echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
21+
mkdir -p ${_HOME} && \
22+
groupadd -f -g "$_GID" "$_LOGIN" && \
23+
useradd -u "$_UID" -g "$_GID" -s /bin/bash -m -d ${_HOME} "${_LOGIN}" && \
24+
chown -R ${_LOGIN} ${_HOME}
25+
26+
RUN yum install --allowerasing -y \
27+
java-11-openjdk jq git sudo && \
28+
yum clean all && \
29+
rm -rf /var/cache/yum

.ci/matrix_job.yaml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ kubernetes:
1717

1818
credentials:
1919
- {credentialsId: 'mellanox_github_credentials', usernameVariable: 'MELLANOX_GH_USER', passwordVariable: 'MELLANOX_GH_TOKEN'}
20+
- {credentialsId: 'blackduck_api_token', type: 'string', variable: 'BLACKDUCK_API_TOKEN'}
2021

2122
volumes:
2223
- {mountPath: /hpc/local/bin, hostPath: /hpc/local/bin}
@@ -25,6 +26,8 @@ volumes:
2526
- {mountPath: /auto/sw_tools/Commercial, hostPath: /auto/sw_tools/Commercial}
2627
- {mountPath: /hpc/local/commercial, hostPath: /hpc/local/commercial}
2728
- {mountPath: /hpc/local/etc/modulefiles, hostPath: /hpc/local/etc/modulefiles}
29+
# for BlackDuck
30+
- {mountPath: /var/home/swx-jenkins, hostPath: /labhome/swx-jenkins}
2831

2932
env:
3033
build_dockers: false
@@ -37,7 +40,7 @@ runs_on_dockers:
3740
- {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'}
3841
- {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'}
3942
- {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'}
43+
- {name: 'blackduck', file: '.ci/dockerfiles/Dockerfile.rhel8.6', category: 'tool', arch: 'x86_64', tag: '20250422', uri: 'sockperf/$arch/$name/bduck', build_args: '--no-cache'}
4144
- {name: 'header-check', url: 'harbor.mellanox.com/toolbox/header_check:0.0.51', category: 'tool', arch: 'x86_64', tag: '0.0.51'}
4245

4346
runs_on_agents:
@@ -242,20 +245,14 @@ steps:
242245
- "{name: 'blackduck', category:'tool', variant:1}"
243246
agentSelector:
244247
- "{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=="}'
248+
run: |
249+
# WA for possible CI-Demo bug: HPCINFRA-1614
250+
if ${do_blackduck} ; then
251+
.ci/blackduck_source.sh
252+
fi
253+
archiveArtifacts: 'logs/'
254+
credentialsId:
255+
- "blackduck_api_token"
259256

260257
pipeline_start:
261258
run: |

0 commit comments

Comments
 (0)