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

39
Jenkinsfile vendored
View File

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