Sfoglia il codice sorgente

BUG fix: ftp packages sort order not by time, fix by krrish, add by:
"ls -rt /opt/ftp/ xxx "

krrish 7 anni fa
parent
commit
1f7300cca9
1 ha cambiato i file con 14 aggiunte e 14 eliminazioni
  1. 14 14
      build/build_images.sh

+ 14 - 14
build/build_images.sh

@@ -73,15 +73,15 @@ function fn_build_images()
     docker push "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"${IMAGE_VERSION}" >"${ERROR_LOG}" 2>&1
     if [ $? -ne 0 ]
     then
-	echo "retry pushing after 3 seconds..."
-	sleep 3 
+        echo "retry pushing after 3 seconds..."
+        sleep 3
         docker push "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"${IMAGE_VERSION}" >"${ERROR_LOG}" 2>&1
         if [ $? -ne 0 ]; then
-	    fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:${IMAGE_VERSION}  failure." || return $?
+      fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:${IMAGE_VERSION}  failure." || return $?
         fi
     fi
 
-    echo 
+    echo
     echo "Ready to push latest image"
     sleep 3
 
@@ -90,19 +90,19 @@ function fn_build_images()
     if [ $? -ne 0 ]
     then
         echo "retry push latest after 3 seconds..."
-	sleep 3 
+        sleep 3
         docker push "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"latest" >"${ERROR_LOG}" 2>&1
         if [ $? -ne 0 ]; then
-	    fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:latest  failure." || return $?
+      fn_print_err "docker push ${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:latest  failure." || return $?
         fi
     fi
 
     sleep 5
     docker pull "${MIRROR_ADDRESS}"/"${PROJECT_NAME}"/"${WANGYUAN_NAME}"/"${images_name}":"latest" >"${ERROR_LOG}" 2>&1
-    if [ $? -ne 0 ] 
+    if [ $? -ne 0 ]
     then
         fn_print_err "Pull<${MIRROR_ADDRESS}/${PROJECT_NAME}/${WANGYUAN_NAME}/${images_name}:latest> failure." || return $?
-    fi  
+    fi
 
     return 0
 
@@ -150,12 +150,12 @@ fn_main()
     MODUL_NAME=$1
     local svn_number=$2
     PROJECT_NAME=$3
-    
+
     #定义日志打印的路径
     BUILD_LOG=/tmp/${MODUL_NAME}/build.log
     ERROR_LOG=/tmp/${MODUL_NAME}/error.log
-   
-    #创建日志文件 
+
+    #创建日志文件
     [ -d /tmp/${MODUL_NAME} ] && rm -rf /tmp/${MODUL_NAME}
     mkdir -p /tmp/${MODUL_NAME}
     cd /tmp/${MODUL_NAME} && touch build.log error.log
@@ -165,8 +165,8 @@ fn_main()
         fn_print_err "Jenkins SVN version or modul name or project name does not exist." || return $?
     fi
 
-    #通过网元模块名和svn版本号找到包名
-    pkg_name=`ls /data/ftp |grep -i ${MODUL_NAME} |grep ${svn_number} |tail -n 1`
+    #通过网元模块名和svn版本号找到包名,取最近一次时间的版本号
+    pkg_name=`ls -rt /data/ftp |grep -i ${MODUL_NAME} |grep ${svn_number} |tail -n 1`
     if [ -z "${pkg_name}" ]
     then
         fn_print_err "SVN version or modul name is Error." || return $?
@@ -198,7 +198,7 @@ fn_main()
     #build镜像
     cd /tmp/${MODUL_NAME}
     tms_success "Start build ${MODUL_NAME} images."
-   
+
     # modify by dongcj
     fn_build_images "${images_name}" >"${ERROR_LOG}" 2>&1
     if [ $? -ne 0 ]