summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorfumingwei <[email protected]>2024-02-05 18:41:44 +0800
committerfumingwei <[email protected]>2024-02-05 18:41:44 +0800
commit5f335fe833f5683f7cade2cb5ebcfaabf7dd6d22 (patch)
treed4c0a1ed738cfe5044c2987908c6e3a09e74a522 /tools
parente02343a18d5c1bea1c83b10053bfd167669f5227 (diff)
feature:add download url content in webhook content.
Diffstat (limited to 'tools')
-rw-r--r--tools/notify-jobs-done.sh81
1 files changed, 70 insertions, 11 deletions
diff --git a/tools/notify-jobs-done.sh b/tools/notify-jobs-done.sh
index 0f1b36c1..e5c1df80 100644
--- a/tools/notify-jobs-done.sh
+++ b/tools/notify-jobs-done.sh
@@ -1,18 +1,77 @@
#!/bin/sh -x
ls -halt $CI_PROJECT_DIR/images/
-TSG_OS_VERSION_FILE="$CI_PROJECT_DIR/images/tsg-os-version.txt"
+HAS_BUILT_FILES="$CI_PROJECT_DIR/images/has-built-files.txt"
+################################################function define start###################################################
+read_tsg_os_version()
+{
+ local has_built_files=$1
+ local tsg_os_version=
+ if [ -f $has_built_files ]; then
+ tsg_os_version=$(cat $has_built_files | grep 'ONIE.bin' | grep -v 'sha256sum.txt' | awk -F '-x86_64' '{print $1}')
+ fi
+ echo $tsg_os_version
+}
-TSG_OS_VERSION=
-if [ -f $TSG_OS_VERSION_FILE ]; then TSG_OS_VERSION=$(cat $TSG_OS_VERSION_FILE); fi
-echo $TSG_OS_VERSION
+#https://repo.geedge.net/filerepo/install/release/tsg-os-images/tsg-os-v24.01.4-57dbca0-x86_64_COTS-ONIE-kvm.img
+build_download_urls()
+{
+ local scheme=$1
+ local domain=$2
+ local subpath=$3
+ local has_build_files=$4
-NOTIFY_CONTENT="{\"msgtype\": \"text\",\"text\": {\"content\": \"TSG-OS version: $TSG_OS_VERSION has been released.\",\"mentioned_list\":[\"@all\"]}}"
-echo $NOTIFY_CONTENT
+ local base_url="$scheme://$domain/$subpath/"
+ local urls=""
+ while IFS= read -r line; do
+ urls="$urls$base_url$line\n"
+ done < $has_build_files
+ echo $urls
+}
-if [ -z "$TSG_OS_VERSION" ]; then echo "TSG_OS version: $TSG_OS_VERSION is NULL."; exit 1; fi
-if [ -n "$ENABLE_NOTIFY_TESTING_JOBS_DONE" ] && [ "$ENABLE_NOTIFY_TESTING_JOBS_DONE" == "1" ]; then curl "$NOTIFY_TESTING_JOBS_DONE_WEBHOOK" -H "Content-Type: application/json" -d "$NOTIFY_CONTENT"; fi
-if [ -n "$ENABLE_NOTIFY_RC_JOBS_DONE" ] && [ "$ENABLE_NOTIFY_RC_JOBS_DONE" == "1" ]; then curl "$NOTIFY_RC_JOBS_DONE_WEBHOOK" -H "Content-Type: application/json" -d "$NOTIFY_CONTENT"; fi
-if [ -n "$ENABLE_NOTIFY_RELEASE_JOBS_DONE" ] && [ "$ENABLE_NOTIFY_RELEASE_JOBS_DONE" == "1" ]; then curl "$NOTIFY_RELEASE_JOBS_DONE_WEBHOOK" -H "Content-Type: application/json" -d "$NOTIFY_CONTENT"; fi
+build_notify_content()
+{
+ local aliyun_url_subpath=$1
+ local bj_office_url_subpath=$2
+ local tsg_os_version=$3
+ local has_built_files=$4
-rm -rf $TSG_OS_VERSION_FILE \ No newline at end of file
+ bj_download_urls=$(build_download_urls https repo.geedge.net $aliyun_url_subpath $has_built_files)
+ de_download_urls=$(build_download_urls https de.repo.gdnt-cloud.com $aliyun_url_subpath $has_built_files)
+ sg_download_urls=$(build_download_urls https sg.repo.gdnt-cloud.com $aliyun_url_subpath $has_built_files)
+ bj_office_download_urls=$(build_download_urls http 192.168.44.24 $bj_office_url_subpath $has_built_files)
+
+ title_content="$tsg_os_version has been built. You can download it from the nearest mirror site.\n"
+ bj_content="Beijing:\n$bj_download_urls"
+ de_content="Berlin:\n$de_download_urls"
+ sg_content="Singapore:\n$sg_download_urls"
+ bj_office_content="Beijing Office (accessible only from the Beijing Office):\n$bj_office_download_urls"
+
+ #echo "$notify_content_title$notify_content_bj$notify_content_de$notify_content_sg$notify_content_xxg"
+ echo "{\"msgtype\": \"text\",\"text\": {\"content\": \"$title_content$bj_content$de_content$sg_content$bj_office_content\"}}"
+}
+
+#################################################function define end####################################################
+
+TSG_OS_VERSION=$(read_tsg_os_version $HAS_BUILT_FILES)
+if [ -z "$TSG_OS_VERSION" ]; then
+ echo "TSG_OS version: $TSG_OS_VERSION is NULL."
+ exit 1
+fi
+
+if [ -n "$ENABLE_NOTIFY_TESTING_JOBS_DONE" ] && [ "$ENABLE_NOTIFY_TESTING_JOBS_DONE" == "1" ]; then
+ notify_content=$(build_notify_content filerepo/install/testing/tsg-os-images tsg-os/testing $TSG_OS_VERSION $HAS_BUILT_FILES)
+ curl "$NOTIFY_TESTING_JOBS_DONE_WEBHOOK" -H "Content-Type: application/json" -d "$notify_content"
+fi
+
+if [ -n "$ENABLE_NOTIFY_RC_JOBS_DONE" ] && [ "$ENABLE_NOTIFY_RC_JOBS_DONE" == "1" ]; then
+ notify_content=$(build_notify_content filerepo/install/rc/tsg-os-images tsg-os/rc $TSG_OS_VERSION $HAS_BUILT_FILES)
+ curl "$NOTIFY_RC_JOBS_DONE_WEBHOOK" -H "Content-Type: application/json" -d "$notify_content"
+fi
+
+if [ -n "$ENABLE_NOTIFY_RELEASE_JOBS_DONE" ] && [ "$ENABLE_NOTIFY_RELEASE_JOBS_DONE" == "1" ]; then
+ notify_content=$(build_notify_content filerepo/install/release/tsg-os-images tsg-os/release $TSG_OS_VERSION $HAS_BUILT_FILES)
+ curl "$NOTIFY_RELEASE_JOBS_DONE_WEBHOOK" -H "Content-Type: application/json" -d "$notify_content"
+fi
+
+rm -rf $HAS_BUILT_FILES \ No newline at end of file