Skip to content

Commit fb06be3

Browse files
committed
[CI] Issue: HPCINFRA-3441 move antivirus scan to release job
Move the antivirus scan step from the regular matrix file to the release matrix file Signed-off-by: Noam Tsemah <[email protected]>
1 parent 5fd84fb commit fb06be3

File tree

6 files changed

+48
-61
lines changed

6 files changed

+48
-61
lines changed

.ci/antivirus.sh

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,38 @@
11
#!/bin/bash -Exel
2+
set -o pipefail
23

34
echo -e "\n\n**********************************"
45
echo -e "\n\nStarting antivirus.sh script...\n\n"
56
echo -e "**********************************\n\n"
67

7-
if [ -z "$1" ]; then
8-
if [ -z "${release_folder}" ]; then
9-
echo "ERROR: Please use the first script argument or env var 'release_folder'. Exit"
10-
fi
11-
else
12-
release_folder=$1
13-
fi
14-
if [ ! -e "${release_folder}" ] || [ ! -d "${release_folder}" ]; then
15-
echo "ERROR: [${release_folder}] directory doesn't exist. Exit"
16-
exit 1
17-
fi
8+
[[ -z "${WORKSPACE}" ]] && { echo "ERROR: WORKSPACE variable is empty. Exit"; exit 1; }
9+
[[ ! -d "${WORKSPACE}" ]] && { echo "ERROR: ${WORKSPACE} does not exist. Exit"; exit 1; }
10+
[[ -z "${release_folder}" ]] && { echo "ERROR: release_folder variable is empty. Exit"; exit 1; }
11+
[[ ! -d "${release_folder}" ]] && { echo "ERROR: ${release_folder} does not exist. Exit"; exit 1; }
12+
[[ -z "${release_tag}" ]] && { echo "ERROR: release_tag variable is empty. Exit"; exit 1; }
13+
[[ ! -d "${release_folder}/${release_tag}" ]] && { echo "ERROR: ${release_folder}/${release_tag} does not exist. Exit"; exit 1; }
1814

19-
if [ -z "$2" ]; then
20-
if [ -z "${release_version}" ]; then
21-
echo "ERROR: Please use the second script argument or env var 'release_version'. Exit"
22-
fi
23-
else
24-
release_version=$2
25-
echo "FULL_VERSION from script parameter: [${release_version}]"
26-
fi
27-
if [ -z "${release_version}" ]; then
28-
release_version=$(git describe --tags $(git rev-list --tags --max-count=1))
15+
if [ -z "${revision}" ]; then
16+
echo "WARN: 'revision' was not set, defaulting to 1"
17+
revision=1
2918
fi
3019

31-
mkdir -p logs
20+
mkdir -p "${WORKSPACE}/logs/"
21+
cd "${release_folder}/${release_tag}/"
3222

33-
cd ${release_folder}/${release_version}/
34-
pkg_name=$(ls -1 libxlio-*.src.rpm)
23+
pkg_name="libxlio-${release_tag}-${revision}.src.rpm"
24+
tarball_name="libxlio-${release_tag}.tar.gz"
25+
rpm_log="${WORKSPACE}/logs/${pkg_name}_antivirus.log"
26+
tarball_log="${WORKSPACE}/logs/${tarball_name}_antivirus.log"
3527

36-
export PROJECT_SRC_PATH=${release_folder}/${release_version}/$pkg_name
37-
LOG=$WORKSPACE/logs/${name}_antivirus.log
28+
[[ ! -e "${pkg_name}" ]] && { echo "ERROR: ${release_folder}/${release_tag}/${pkg_name} does not exist. Exit"; exit 1; }
29+
[[ ! -e "${tarball_name}" ]] && { echo "ERROR: ${release_folder}/${release_tag}/${tarball_name} does not exist. Exit"; exit 1; }
3830

39-
sudo -E -u swx-jenkins /auto/GLIT/SCRIPTS/HELPERS/antivirus-scan.sh $PROJECT_SRC_PATH 2>&1 | tee $LOG
31+
/auto/GLIT/SCRIPTS/HELPERS/antivirus-scan.sh "${release_folder}/${release_tag}/${pkg_name}" 2>&1 | tee "${rpm_log}" || true
32+
/auto/GLIT/SCRIPTS/HELPERS/antivirus-scan.sh "${release_folder}/${release_tag}/${tarball_name}" 2>&1 | tee "${tarball_log}" || true
4033

41-
cat $LOG | grep 'Possibly Infected:............. 0'
42-
if [ $? -ne 0 ];then
43-
status=1
34+
if grep -q 'Possibly Infected:............. 0' "${rpm_log}" && grep -q 'Possibly Infected:............. 0' "${tarball_log}"; then
35+
exit 0
4436
else
45-
status=0
37+
exit 1
4638
fi
47-
exit $status

.ci/do_release.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo "**********************************"
77
set -o pipefail
88

99
print_help() {
10-
set +xv
10+
set +xv
1111
echo -e "\n\n"
1212
echo "--------------------------------------------------"
1313
echo "Usage: release_folder=<release folder> release_tag=<release tag> [revision=<revision>] [do_release=<true|false>] $0"
@@ -50,7 +50,7 @@ configure_ac_version="${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}"
5050
pkg_folder=pkg/packages
5151
pkg_name="libxlio-${release_tag}-${revision}.src.rpm"
5252
tarball_name="libxlio-${release_tag}.tar.gz"
53-
DST_DIR=${release_folder}/${release_tag}
53+
DST_DIR="${release_folder}/${release_tag}"
5454
echo "FULL_VERSION from configure.ac: [${configure_ac_version}]"
5555

5656
# Creating both tarball and src.rpm
@@ -63,28 +63,28 @@ fi
6363

6464
if [ "${do_release}" = true ] ; then
6565
echo "do_release is set to true, will release package into ${release_folder}/${release_tag}"
66-
66+
6767
if [ ! -d "${pkg_folder}" ]; then
6868
echo "ERROR: pkg folder is missing, exiting..."
6969
exit 1
7070
fi
71-
72-
if [[ -e "${DST_DIR}/${pkg_name}" || -e "${DST_DIR}/${tarball_name}" ]]; then
71+
72+
if [[ -e "${DST_DIR}/${pkg_name}" || -e "${DST_DIR}/${tarball_name}" ]]; then
7373
echo "ERROR: [${DST_DIR}/${pkg_name}] or [${DST_DIR}/${tarball_name}] file already exist. Exit"
7474
exit 1
7575
fi
7676

7777
files_dir=$(pwd)
7878
pushd "${release_folder}" || { echo "ERROR: Failed to pushd to ${release_folder}. Exit" ; exit 1; }
79-
sudo -E -u swx-jenkins mkdir -p "$DST_DIR"
79+
mkdir -p "${DST_DIR}"
8080
# Copy both the src.rpm and the tarball to the destination
81-
sudo -E -u swx-jenkins cp -v "${files_dir}/${pkg_folder}/${pkg_name}" "${DST_DIR}"
82-
sudo -E -u swx-jenkins cp -v "${files_dir}/${pkg_folder}/${tarball_name}" "${DST_DIR}"
81+
cp -v "${files_dir}/${pkg_folder}/${pkg_name}" "${DST_DIR}"
82+
cp -v "${files_dir}/${pkg_folder}/${tarball_name}" "${DST_DIR}"
8383

84-
sudo -E -u swx-jenkins ln -s "$DST_DIR/${pkg_name}" "${pkg_name}"
84+
ln -s "${DST_DIR}/${pkg_name}" "${pkg_name}"
8585
popd || { echo "ERROR: Failed to popd from ${release_folder}. Exit" ; exit 1; }
8686

87-
echo "INFO: Release found at $DST_DIR"
87+
echo "INFO: Release found at ${DST_DIR}"
8888
else
8989
echo "INFO: do_release is set to false, skipping package release."
9090
fi

.ci/matrix_job.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ volumes:
3434
- {mountPath: /auto/sw_tools/Commercial, hostPath: /auto/sw_tools/Commercial}
3535
- {mountPath: /hpc/local/commercial, hostPath: /hpc/local/commercial}
3636
- {mountPath: /hpc/local/etc/modulefiles, hostPath: /hpc/local/etc/modulefiles}
37-
# for Antivirus
38-
- {mountPath: /auto/BACKUP/logs_of_LOGS, hostPath: /auto/BACKUP/logs_of_LOGS}
39-
- {mountPath: /auto/GLIT/SCRIPTS/HELPERS, hostPath: /auto/GLIT/SCRIPTS/HELPERS}
4037
# Default release location
4138
- {mountPath: /auto/sw/release/sw_acceleration, hostPath: /auto/sw/release/sw_acceleration}
4239
# User profile for release
@@ -295,16 +292,6 @@ steps:
295292
archiveArtifacts-onfail: |
296293
jenkins/**/arch-*.tar.gz
297294
298-
- name: Antivirus
299-
enable: ${do_antivirus}
300-
containerSelector:
301-
- "{name: 'rhel8.3-mofed-x86_64', category: 'base', variant: 1}"
302-
agentSelector:
303-
- "{nodeLabel: 'skip-agent'}"
304-
run: |
305-
env WORKSPACE=$PWD .ci/antivirus.sh ${release_folder}
306-
archiveArtifacts: 'logs/'
307-
308295
- name: Style
309296
enable: ${do_style}
310297
containerSelector:

.ci/opensource_jjb.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
name: "do_package"
5454
default: true
5555
description: "Check tar, source and binary packages."
56-
- bool:
57-
name: "do_antivirus"
58-
default: false
59-
description: "Run Antivirus."
6056
- bool:
6157
name: "do_cppcheck"
6258
default: true

.ci/pipeline/release_jjb.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
name: "do_release"
3636
default: true
3737
description: "Release build packges into the release folder, set to false for debugging"
38+
- bool:
39+
name: "do_antivirus"
40+
default: true
41+
description: "Run Antivirus."
3842
- string:
3943
name: "notification_email"
4044
default: "{jjb_release_email}"

.ci/pipeline/release_matrix_job.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ volumes:
2525
- {mountPath: /auto/sw/release/sw_acceleration, hostPath: /auto/sw/release/sw_acceleration}
2626
# User profile for release
2727
- {mountPath: /var/home/swx-jenkins, hostPath: /labhome/swx-jenkins}
28+
# for Antivirus
29+
- {mountPath: /auto/GLIT/SCRIPTS/HELPERS, hostPath: /auto/GLIT/SCRIPTS/HELPERS}
2830

2931
runs_on_dockers:
3032
- {
@@ -33,10 +35,11 @@ runs_on_dockers:
3335
uri: '$arch/$name/release',
3436
build_args: '--no-cache --target release',
3537
arch: 'x86_64',
36-
tag: '20250304'
38+
tag: '20250304',
39+
runAsUser: '6213',
40+
runAsGroup: '101'
3741
}
3842

39-
4043
steps:
4144
- name: Build-dpcp
4245
parallel: false
@@ -51,6 +54,12 @@ steps:
5154
.ci/do_release.sh
5255
archiveArtifacts: "**/build_pkg.log,**/packages/*.rpm"
5356

57+
- name: Antivirus
58+
enable: ${do_antivirus}
59+
run: |
60+
env WORKSPACE=$PWD .ci/antivirus.sh
61+
archiveArtifacts: 'logs/'
62+
5463
pipeline_start:
5564
shell: action
5665
module: groovy

0 commit comments

Comments
 (0)