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: artifacts:
when: always when: always
paths: paths:
- debug.log
- out/datamodel_default.xml - out/datamodel_default.xml
- out/datamodel_hdm.xml - out/datamodel_hdm.xml
- out/datamodel.xls - out/datamodel.xls

View file

@ -14,108 +14,129 @@ mkdir -p /etc/bbfdm/dmmap
[ ! -d "${BBFDM_MS_DIR}" ] && mkdir -p "${BBFDM_MS_DIR}" [ ! -d "${BBFDM_MS_DIR}" ] && mkdir -p "${BBFDM_MS_DIR}"
# Clean up generated files # Clean up generated files
rm -rf ${BBFDM_MS_DIR}/* rm -rf "${BBFDM_MS_DIR:?}"/*
rm -f ${BBFDM_MS_CONF}/* rm -f "${BBFDM_MS_CONF}"/*
rm -f ${BBFDM_DMMAP_DIR}/* rm -f "${BBFDM_DMMAP_DIR}"/*
install_libeasy install_libeasy
# compile and install Core Data Model as a micro-service # 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 if [ "$1" == "bbfdm" ]; then
#compile and install libbbf_test dynamic extension library #compile and install libbbf_test dynamic extension library
install_libbbf_test install_libbbf_test
fi fi
# Install datamodel plugins/micro-service only when pipeline trigger for bbfdm JSON_FILE=$BBFDM_TOOLS_INPUT_FILE
if [ -z "${1}" ]; then JSON_DESC_PATH="/tmp/desc_files"
echo "Skip installation of micro-services ...." plugin_count=$(jq '.plugins | length' "$JSON_FILE")
else
JSON_FILE=$BBFDM_TOOLS_INPUT_FILE
JSON_DESC_PATH="/tmp/desc_files"
plugin_count=$(jq '.plugins | length' "$JSON_FILE")
# Create desc_files directory # Create desc_files directory
[ -d "${JSON_DESC_PATH}" ] && rm -f ${JSON_DESC_PATH} [ -d "${JSON_DESC_PATH}" ] && rm -f ${JSON_DESC_PATH}
mkdir -p ${JSON_DESC_PATH} mkdir -p ${JSON_DESC_PATH}
for i in $(seq 0 $((plugin_count - 1))); do ret=0
echo "==== Processing plugin [$i] ====" for i in $(seq 0 $((plugin_count - 1))); do
echo "==== Processing plugin [$i] ===="
repo=$(jq -r ".plugins[$i].repo" "$JSON_FILE") repo=$(jq -r ".plugins[$i].repo" "$JSON_FILE")
version=$(jq -r ".plugins[$i].version // empty" "$JSON_FILE") version=$(jq -r ".plugins[$i].version // empty" "$JSON_FILE")
if [ -z "${version}" ]; then if [ -z "${version}" ]; then
version=${BRANCH:-devel} version=${BRANCH:-devel}
fi fi
plugin_name=$(basename "$repo" .git) plugin_name=$(basename "$repo" .git)
dest="$BBFDM_PLUGIN_DEST/$plugin_name" dest="$BBFDM_PLUGIN_DEST/$plugin_name"
# Adjust repo URL based on ~/.netrc existence # Adjust repo URL based on ~/.netrc existence
NETRC_PATH="$HOME/.netrc" NETRC_PATH="$HOME/.netrc"
if [ ! -f "$NETRC_PATH" ]; then if [ ! -f "$NETRC_PATH" ]; then
repo=${repo/https:\/\/dev.iopsys.eu\//git@dev.iopsys.eu:} repo=${repo/https:\/\/dev.iopsys.eu\//git@dev.iopsys.eu:}
fi fi
echo "Repo path: $repo" echo "Repo path: $repo"
echo "Plugin name: $plugin_name" echo "Plugin name: $plugin_name"
echo "Destination: $dest" echo "Destination: $dest"
echo "Version: $version" echo "Version: $version"
# Install dependencies # Install dependencies
if [ "$plugin_name" == "ethmngr" ]; then if [ "$plugin_name" == "ethmngr" ]; then
install_libethernet install_libethernet
install_libqos install_libqos
fi fi
if [ "$plugin_name" == "parental-control" ]; then if [ "$plugin_name" == "parental-control" ]; then
install_cmph install_cmph
fi fi
if [ -d "$dest" ]; then if [ -d "$dest" ]; then
echo "Directory $dest already exists, skipping clone." echo "Directory $dest already exists, checkout $version"
else (cd "$dest" && git checkout . && git checkout "$version")
echo "Cloning $repo into $dest, branch ${version} ..." else
git clone -b "$version" "$repo" "$dest" || { echo "❌ Git clone failed"; exit -1; } echo "Cloning $repo into $dest, branch ${version} ..."
fi exec_cmd git clone -b "$version" "$repo" "$dest"
fi
cd $dest cd "$dest" || exit 5
# Compilation # Compilation
compile="$(jq -r ".plugins[$i].compile[]" "$JSON_FILE" 2>/dev/null)" compile="$(jq -r ".plugins[$i].compile[]" "$JSON_FILE" 2>/dev/null)"
if [ -n "${compile}" ]; then if [ -n "${compile}" ]; then
echo "Starting compilation..." 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" echo "Executing: $cmd"
eval "$cmd" || { echo "❌ Compilation command failed"; exit -1; } if ! eval "$cmd" > debug.log 2>&1; then
done echo "❌ Compilation command [$cmd] failed"
fi ret=1
break
# 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
echo "Executing: $post_cmd"
eval "$post_cmd" || { echo "❌ Post-install command failed"; exit -1; }
done
fi
# Save dm_info_file if defined
dm_info_file=$(jq -r ".plugins[$i].dm_info_file // empty" "$JSON_FILE")
if [ -n "$dm_info_file" ]; then
src_file="$dest/$dm_info_file"
out_file="/tmp/desc_files/${i}_${plugin_name}.json"
if [ -f "$src_file" ]; then
echo "Saving dm_info_file to $out_file"
cp -f "$src_file" "$out_file"
else
echo "❌ dm_info_file not found: $src_file"
fi 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..."
while read -r post_cmd; do
echo "Executing: $post_cmd"
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
dm_info_file=$(jq -r ".plugins[$i].dm_info_file // empty" "$JSON_FILE")
if [ -n "$dm_info_file" ]; then
src_file="$dest/$dm_info_file"
out_file="/tmp/desc_files/${i}_${plugin_name}.json"
if [ -f "$src_file" ]; then
echo "Saving dm_info_file to $out_file"
cp -f "$src_file" "$out_file"
else
echo "❌ dm_info_file not found: $src_file"
ret=1
fi fi
fi
cd $(pwd) cd .. || exit 7
if [ ${ret} -eq 0 ]; then
echo "✅ Plugin [$plugin_name] build complete." echo "✅ Plugin [$plugin_name] build complete."
done else
fi 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\"", "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", "cmake -DBBF_VENDOR_PREFIX:String=X_IOWRT_EU_ -DTR104_EXTENSION_DIR:String=iowrt -DRUNAS_BBFDM_MICROSERVICE:BOOL=ON",
"cd libdm", "cd libdm",
"make" "make",
"cd -"
], ],
"post_install": [ "post_install": [
"cp -f libdm/tr104/libtr104.so /usr/share/bbfdm/micro_services/tr104.so", "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", "repo": "https://dev.iopsys.eu/feed/gnx.git",
"proto": "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": [ "post_install": [
"mkdir -p /usr/share/bbfdm/micro_services/ethmngr", "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": [ "compile": [
"cd genexis-packages/gnx-ux-manager", "cd genexis-packages/gnx-ux-manager",
"cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/", "cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/",
"make" "make",
"cd -"
], ],
"post_install": [ "post_install": [
"cp -f genexis-packages/gnx-ux-manager/libleddm.so /usr/share/bbfdm/micro_services/gnx-ux-manager.so", "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", "dm_info_file": "genexis-packages/gnx-catv/datamodel/datamodel_description.json",
"compile": [ "compile": [
"cd genexis-packages/gnx-catv", "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": [ "post_install": [
"cp -f genexis-packages/gnx-catv/datamodel/libgnx-bbf-catv.so /usr/share/bbfdm/micro_services/gnx-catv.so", "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", "dm_info_file": "genexis-packages/dhcp-on-boarding/src/datamodel_description.json",
"compile": [ "compile": [
"cd genexis-packages/dhcp-on-boarding", "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": [ "post_install": [
"cp -f genexis-packages/dhcp-on-boarding/src/lib_dhcp_onboarding.so /usr/share/bbfdm/micro_services/dhcp-on-boarding.so", "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", "dm_info_file": "genexis-packages/gnx-loop-detector/datamodel/datamodel_description.json",
"compile": [ "compile": [
"cd genexis-packages/gnx-loop-detector", "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": [ "post_install": [
"cp -f genexis-packages/gnx-loop-detector/datamodel/libloopdetection.so /usr/share/bbfdm/micro_services/gnx-loop-detector.so", "cp -f genexis-packages/gnx-loop-detector/datamodel/libloopdetection.so /usr/share/bbfdm/micro_services/gnx-loop-detector.so",
@ -667,7 +672,8 @@
"compile": [ "compile": [
"cd genexis-packages/gnx-sfp", "cd genexis-packages/gnx-sfp",
"cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_C_FLAGS='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'", "cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_C_FLAGS='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'",
"make" "make",
"cd -"
], ],
"post_install": [ "post_install": [
"cp -f genexis-packages/gnx-sfp/libopticaldm.so /usr/share/bbfdm/micro_services/gnx-sfp.so", "cp -f genexis-packages/gnx-sfp/libopticaldm.so /usr/share/bbfdm/micro_services/gnx-sfp.so",