diff --git a/Jenkinsfile b/Jenkinsfile index 85f51fe..1dca002 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ // ============================================ // AIOT Platform - Jenkins Pipeline (Optimized) -// 修复序列化问题 + 并行构建 + 优化部署 +// 修复序列化问?+ 并行构建 + 优化部署 // ============================================ pipeline { @@ -29,8 +29,8 @@ pipeline { // 性能配置 MAX_PARALLEL_BUILDS = 2 - HEALTH_CHECK_TIMEOUT = 120 // 秒 - HEALTH_CHECK_INTERVAL = 5 // 秒 + HEALTH_CHECK_TIMEOUT = 120 // ? + HEALTH_CHECK_INTERVAL = 5 // ? } stages { @@ -80,7 +80,7 @@ pipeline { docker push ${DEPS_IMAGE} """ - echo "✅ Dependencies image built and pushed" + echo "?Dependencies image built and pushed" } } } @@ -100,12 +100,12 @@ pipeline { } } - // 限制并发数 + // 限制并发? parallel buildTasks - echo "✅ All services built successfully" + echo "?All services built successfully" - // 清理旧镜像 + // 清理旧镜? sh "docker image prune -f || true" } } @@ -122,7 +122,7 @@ pipeline { script { def servicesToDeploy = env.SERVICES_TO_BUILD.split(',') - // 按依赖顺序排序 + // 按依赖顺序排? def sortedServices = sortServicesByDependency(servicesToDeploy) echo "🚀 Deploying ${sortedServices.size()} services in order" @@ -158,10 +158,10 @@ pipeline { } } - // 并行健康检查 + // 并行健康检? parallel healthCheckTasks - echo "✅ All services are healthy" + echo "?All services are healthy" } } } @@ -170,13 +170,13 @@ pipeline { post { success { echo """ - ✅ 构建成功 + ?构建成功 📦 Services: ${env.SERVICES_TO_BUILD} - 🏷️ Tag: ${IMAGE_TAG} + 🏷? Tag: ${IMAGE_TAG} """ } failure { - echo "❌ 构建失败,请检查日志" + echo "?构建失败,请检查日? } always { sh 'df -h | grep -E "/$|/var" || true' @@ -186,7 +186,7 @@ pipeline { } // ============================================ -// 辅助函数(使用 @NonCPS 避免序列化问题) +// 辅助函数(使?@NonCPS 避免序列化问题) // ============================================ @NonCPS @@ -203,7 +203,7 @@ def detectChangedServices() { return env.CORE_SERVICES } - // 触发全量构建的文件 + // 触发全量构建的文? def triggerAll = ['pom.xml', 'viewsh-framework', 'viewsh-dependencies', 'Jenkinsfile', 'docker/'] if (triggerAll.any { changedFiles.contains(it) }) { return env.CORE_SERVICES @@ -272,7 +272,7 @@ def buildService(String service) { docker push ${REGISTRY}/${service}:latest """ - echo "✅ ${service} built and pushed" + echo "?${service} built and pushed" } // 部署单个服务 @@ -297,7 +297,7 @@ def deployService(String service) { // 等待服务健康 waitForServiceHealthy(containerName, service, sshOpts) - echo "✅ ${service} deployed successfully" + echo "?${service} deployed successfully" } // 等待服务健康 @@ -311,21 +311,21 @@ def waitForServiceHealthy(String containerName, String serviceName, String sshOp STATUS=\$(docker inspect --format="{{.State.Health.Status}}" ${containerName} 2>/dev/null || echo "starting") if [ "\$STATUS" = "healthy" ]; then - echo "✅ ${serviceName} is healthy" + echo "?${serviceName} is healthy" exit 0 elif [ "\$STATUS" = "unhealthy" ]; then - echo "❌ ${serviceName} is unhealthy" + echo "?${serviceName} is unhealthy" echo "=== Last 100 lines of logs ===" docker logs --tail 100 ${containerName} exit 1 fi ELAPSED=\$((i * ${HEALTH_CHECK_INTERVAL})) - echo "⏳ ${serviceName} status: \$STATUS (\${ELAPSED}s/${HEALTH_CHECK_TIMEOUT}s)" + echo "?${serviceName} status: \$STATUS (\${ELAPSED}s/${HEALTH_CHECK_TIMEOUT}s)" sleep ${HEALTH_CHECK_INTERVAL} done - echo "❌ ${serviceName} health check timeout after ${HEALTH_CHECK_TIMEOUT}s" + echo "?${serviceName} health check timeout after ${HEALTH_CHECK_TIMEOUT}s" echo "=== Full logs ===" docker logs ${containerName} exit 1 @@ -333,7 +333,7 @@ def waitForServiceHealthy(String containerName, String serviceName, String sshOp """ } -// 检查服务健康状态 +// 检查服务健康状? def checkServiceHealth(String containerName, String serviceName) { def sshOpts = "-o StrictHostKeyChecking=no -o ConnectTimeout=10 -i ${SSH_KEY}" @@ -342,11 +342,11 @@ def checkServiceHealth(String containerName, String serviceName) { echo "Checking ${serviceName}..." STATUS=\$(docker inspect --format="{{.State.Health.Status}}" ${containerName} 2>/dev/null || echo "not_found") if [ "\$STATUS" = "healthy" ]; then - echo "✅ ${serviceName} is healthy" + echo "?${serviceName} is healthy" elif [ "\$STATUS" = "not_found" ]; then echo "⚠️ ${serviceName} not found (may not be deployed)" else - echo "❌ ${serviceName} is \$STATUS" + echo "?${serviceName} is \$STATUS" docker logs --tail 50 ${containerName} exit 1 fi @@ -354,7 +354,7 @@ def checkServiceHealth(String containerName, String serviceName) { """ } -// 按依赖顺序排序服务 +// 按依赖顺序排序服? @NonCPS def sortServicesByDependency(def services) { def deployOrder = [ @@ -370,7 +370,7 @@ def sortServicesByDependency(def services) { } } -// 获取服务对应的容器名称 +// 获取服务对应的容器名? @NonCPS def getContainerNameForService(String service) { switch(service) { @@ -389,7 +389,7 @@ def getContainerNameForService(String service) { } } -// 获取服务对应的模块路径 +// 获取服务对应的模块路? @NonCPS def getModulePathForService(String service) { switch(service) {