Jelajahi Sumber

修改docker配置

zq940222 2 bulan lalu
induk
melakukan
f79a9a0901
1 mengubah file dengan 10 tambahan dan 7 penghapusan
  1. 10 7
      Jenkinsfile

+ 10 - 7
Jenkinsfile

@@ -38,18 +38,21 @@ node {
     def PROJECT_SERVICE_NAME_SELECT = "${PROJECT_SERVICE_NAME}".split(",")
     // 获取选择的服务器名称
     def PUBLISH_SSH_SERVER_SELECT = "${PUBLISH_SSH_SERVER}".split(",")
+    // maven 和 jdk 工具路径
+    def mavenHome = tool name: 'Maven-3.8.5', type: 'Maven'
+    def jdkHome = tool name: 'JDK8', type: 'JDK'
     // git分支tag
     def GIT_BRANCH_TAG = ""
     // docker镜像仓库认证命令
     def DOCKER_REGISTRY_AUTH_CMD = ""
 
-    tools{
-        maven 'Maven-3.8.5'
-        jdk 'JDK8'
-    }
-
     stage('初始化准备') {
         echo '****************************** 初始化准备 ******************************'
+        echo "JDK路径: ${jdkHome}"
+        echo "Maven路径: ${mavenHome}"
+
+        // 使用JDK工具
+        env.JAVA_HOME = jdkHome
         // 网卡值设置 [注:正常liunx取eth0的内网ip,局域网取enp5s0的内网ip]
         ETH_VALUE = sh(script: "( [[ \"${JAVA_OPTS}\" = *'-Dspring.cloud.nacos.discovery.ip'* ]] && echo enp5s0 || echo eth0 )", returnStdout: true).trim()
         CURRENT_TIME = sh(script: "echo `date +\"%Y-%m-%d %H:%M:%S\"`", returnStdout: true).trim()
@@ -88,7 +91,7 @@ node {
             echo '****************************** 公共工程打包 - 跳过 ******************************'
         } else {
             echo '****************************** 公共工程打包 ******************************'
-            sh "mvn -f ${PROJECT_SERVICE_COMMON_NAME} clean install -Dmaven.test.skip=true"
+            sh "${mavenHome}/bin/mvn -f ${PROJECT_SERVICE_COMMON_NAME} clean install -Dmaven.test.skip=true"
         }
     }
 
@@ -124,7 +127,7 @@ node {
 
 
             if ("${IS_SKIP_BUILD}" != "true") {
-                sh "mvn -f ${current_app_parent}/${current_app_name} clean install -Dmaven.test.skip=true"
+                sh "${mavenHome}/bin/mvn -f ${current_app_parent}/${current_app_name} clean install -Dmaven.test.skip=true"
 
                 sh "cp ${current_app_parent}/${current_app_name}/target/${current_app_jar} ${JENKINS_WORKSPACE}/docker"
             }