Pipeline improvement

This commit is contained in:
Vivek Kumar Dutta 2025-09-10 14:33:49 +05:30
parent 19db3c2d17
commit 227d121ee5
No known key found for this signature in database
GPG key ID: 4E09F5AD8265FD4C
3 changed files with 116 additions and 88 deletions

View file

@ -56,6 +56,7 @@ run_tools_test:
artifacts:
when: always
paths:
- debug.log
- out/datamodel_default.xml
- out/datamodel_hdm.xml
- out/datamodel.xls

View file

@ -14,32 +14,35 @@ mkdir -p /etc/bbfdm/dmmap
[ ! -d "${BBFDM_MS_DIR}" ] && mkdir -p "${BBFDM_MS_DIR}"
# Clean up generated files
rm -rf ${BBFDM_MS_DIR}/*
rm -f ${BBFDM_MS_CONF}/*
rm -f ${BBFDM_DMMAP_DIR}/*
rm -rf "${BBFDM_MS_DIR:?}"/*
rm -f "${BBFDM_MS_CONF}"/*
rm -f "${BBFDM_DMMAP_DIR}"/*
install_libeasy
# compile and install Core Data Model as a micro-service
install_libbbf ${1}
install_libbbf "${1}"
# Install datamodel plugins/micro-service only when pipeline trigger for bbfdm
if [ -z "${1}" ]; then
echo "Skip installation of micro-services ...."
exit 0
fi
if [ "$1" == "bbfdm" ]; then
#compile and install libbbf_test dynamic extension library
install_libbbf_test
fi
# Install datamodel plugins/micro-service only when pipeline trigger for bbfdm
if [ -z "${1}" ]; then
echo "Skip installation of micro-services ...."
else
JSON_FILE=$BBFDM_TOOLS_INPUT_FILE
JSON_DESC_PATH="/tmp/desc_files"
plugin_count=$(jq '.plugins | length' "$JSON_FILE")
JSON_FILE=$BBFDM_TOOLS_INPUT_FILE
JSON_DESC_PATH="/tmp/desc_files"
plugin_count=$(jq '.plugins | length' "$JSON_FILE")
# Create desc_files directory
[ -d "${JSON_DESC_PATH}" ] && rm -f ${JSON_DESC_PATH}
mkdir -p ${JSON_DESC_PATH}
# Create desc_files directory
[ -d "${JSON_DESC_PATH}" ] && rm -f ${JSON_DESC_PATH}
mkdir -p ${JSON_DESC_PATH}
for i in $(seq 0 $((plugin_count - 1))); do
ret=0
for i in $(seq 0 $((plugin_count - 1))); do
echo "==== Processing plugin [$i] ===="
repo=$(jq -r ".plugins[$i].repo" "$JSON_FILE")
@ -73,32 +76,43 @@ else
fi
if [ -d "$dest" ]; then
echo "Directory $dest already exists, skipping clone."
echo "Directory $dest already exists, checkout $version"
(cd "$dest" && git checkout . && git checkout "$version")
else
echo "Cloning $repo into $dest, branch ${version} ..."
git clone -b "$version" "$repo" "$dest" || { echo "❌ Git clone failed"; exit -1; }
exec_cmd git clone -b "$version" "$repo" "$dest"
fi
cd $dest
cd "$dest" || exit 5
# Compilation
compile="$(jq -r ".plugins[$i].compile[]" "$JSON_FILE" 2>/dev/null)"
if [ -n "${compile}" ]; then
echo "Starting compilation..."
jq -r ".plugins[$i].compile[]" "$JSON_FILE" 2>/dev/null| while read -r cmd; do
while read -r cmd; do
echo "Executing: $cmd"
eval "$cmd" || { echo "❌ Compilation command failed"; exit -1; }
done
if ! eval "$cmd" > debug.log 2>&1; then
echo "❌ Compilation command [$cmd] failed"
ret=1
break
fi
done <<< ${compile}
[ $ret -eq 1 ] && break
fi
# Post-install
post_install="$(jq -r ".plugins[$i].post_install[]" "$JSON_FILE" 2>/dev/null)"
if [ -n "${post_install}" ]; then
echo "Running post-install steps..."
jq -r ".plugins[$i].post_install[]" "$JSON_FILE" 2>/dev/null| while read -r post_cmd; do
while read -r post_cmd; do
echo "Executing: $post_cmd"
eval "$post_cmd" || { echo "❌ Post-install command failed"; exit -1; }
done
if ! eval "$post_cmd" > debug.log 2>&1; then
ret=1
echo "❌ Post-install command [$post_cmd] failed"
break
fi
done <<< ${post_install}
[ $ret -eq "1" ] && break
fi
# Save dm_info_file if defined
@ -111,11 +125,18 @@ else
cp -f "$src_file" "$out_file"
else
echo "❌ dm_info_file not found: $src_file"
ret=1
fi
fi
cd $(pwd)
cd .. || exit 7
if [ ${ret} -eq 0 ]; then
echo "✅ Plugin [$plugin_name] build complete."
done
fi
else
echo "❌ Plugin [$plugin_name] build failed"
break
fi
done
exit $ret

View file

@ -402,7 +402,8 @@
"export CFLAGS=\"-I/usr/include/libbbfdm-api -Wall\"",
"cmake -DBBF_VENDOR_PREFIX:String=X_IOWRT_EU_ -DTR104_EXTENSION_DIR:String=iowrt -DRUNAS_BBFDM_MICROSERVICE:BOOL=ON",
"cd libdm",
"make"
"make",
"cd -"
],
"post_install": [
"cp -f libdm/tr104/libtr104.so /usr/share/bbfdm/micro_services/tr104.so",
@ -583,10 +584,10 @@
{
"repo": "https://dev.iopsys.eu/feed/gnx.git",
"proto": "git",
"dm_info_file": "package/gnx-files-ftth/bbf_plugin/link_forwarding.json",
"dm_info_file": "genexis-packages/link-state-forwarding/bbf_plugin/link_forwarding.json",
"post_install": [
"mkdir -p /usr/share/bbfdm/micro_services/ethmngr",
"sed 's/{BBF_VENDOR_PREFIX}/X_GENEXIS_EU_/g' package/gnx-files-ftth/bbf_plugin/link_forwarding.json > /usr/share/bbfdm/micro_services/ethmngr/link_forwarding.json"
"sed 's/{BBF_VENDOR_PREFIX}/X_GENEXIS_EU_/g' genexis-packages/link-state-forwarding/bbf_plugin/link_forwarding.json > /usr/share/bbfdm/micro_services/ethmngr/link_forwarding.json"
]
},
{
@ -597,7 +598,8 @@
"compile": [
"cd genexis-packages/gnx-ux-manager",
"cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/",
"make"
"make",
"cd -"
],
"post_install": [
"cp -f genexis-packages/gnx-ux-manager/libleddm.so /usr/share/bbfdm/micro_services/gnx-ux-manager.so",
@ -612,7 +614,8 @@
"dm_info_file": "genexis-packages/gnx-catv/datamodel/datamodel_description.json",
"compile": [
"cd genexis-packages/gnx-catv",
"make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'"
"make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'",
"cd -"
],
"post_install": [
"cp -f genexis-packages/gnx-catv/datamodel/libgnx-bbf-catv.so /usr/share/bbfdm/micro_services/gnx-catv.so",
@ -636,7 +639,8 @@
"dm_info_file": "genexis-packages/dhcp-on-boarding/src/datamodel_description.json",
"compile": [
"cd genexis-packages/dhcp-on-boarding",
"make -C src CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'"
"make -C src CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'",
"cd -"
],
"post_install": [
"cp -f genexis-packages/dhcp-on-boarding/src/lib_dhcp_onboarding.so /usr/share/bbfdm/micro_services/dhcp-on-boarding.so",
@ -651,7 +655,8 @@
"dm_info_file": "genexis-packages/gnx-loop-detector/datamodel/datamodel_description.json",
"compile": [
"cd genexis-packages/gnx-loop-detector",
"make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'"
"make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'",
"cd -"
],
"post_install": [
"cp -f genexis-packages/gnx-loop-detector/datamodel/libloopdetection.so /usr/share/bbfdm/micro_services/gnx-loop-detector.so",
@ -667,7 +672,8 @@
"compile": [
"cd genexis-packages/gnx-sfp",
"cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_C_FLAGS='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'",
"make"
"make",
"cd -"
],
"post_install": [
"cp -f genexis-packages/gnx-sfp/libopticaldm.so /usr/share/bbfdm/micro_services/gnx-sfp.so",