Jenkins file edit
Some checks failed
test/timeline-frontend/pipeline/head There was a failure building this commit

This commit is contained in:
2025-12-30 13:26:46 +08:00
parent 0d103a081f
commit 8952ee0aa8

13
Jenkinsfile vendored
View File

@@ -238,15 +238,15 @@ def deployToEnvironmentWithCompose(String env) {
// 根据部署环境替换后端服务地址 // 根据部署环境替换后端服务地址
switch(env) { switch(env) {
case 'dev': case 'dev':
// 开发环境可能使用特定的后端服务地址 // 开发环境使用特定的后端服务地址
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'dev-backend-service:33333') nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'dev-backend-service:33333')
break break
case 'staging': case 'staging':
// 预发布环境可能使用特定的后端服务地址 // 预发布环境使用特定的后端服务地址
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'staging-backend-service:33333') nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'staging-backend-service:33333')
break break
case 'prod': case 'prod':
// 生产环境可能使用特定的后端服务地址 // 生产环境使用特定的后端服务地址
nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'prod-backend-service:33333') nginxConfContent = nginxConfContent.replaceAll('host.docker.internal:33333', 'prod-backend-service:33333')
break break
default: default:
@@ -257,9 +257,8 @@ def deployToEnvironmentWithCompose(String env) {
// 写入环境特定的 nginx 配置 // 写入环境特定的 nginx 配置
writeFile file: "nginx-${env}.conf", text: nginxConfContent writeFile file: "nginx-${env}.conf", text: nginxConfContent
// 创建 docker-compose.yml 文件,前端服务连接到已存在的后端 // 创建 docker-compose.yml 文件,使用卷挂载覆盖容器内的 nginx 配置
def composeFileContent = """version: '3.8' def composeFileContent = """services:
services:
frontend: frontend:
image: ${imageToDeploy} image: ${imageToDeploy}
container_name: ${containerName} container_name: ${containerName}
@@ -267,7 +266,7 @@ def deployToEnvironmentWithCompose(String env) {
ports: ports:
- "${getPortForEnvironment(env)}:80" - "${getPortForEnvironment(env)}:80"
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" # 兼容 Docker Desktop - "host.docker.internal:host-gateway" # 允许访问宿主机
networks: networks:
- app-network - app-network