暂存提交
This commit is contained in:
Vendored
+34
-4
@@ -17,6 +17,20 @@ def serviceJars = [
|
||||
'audit-service': 'audit-service/target/audit-service-1.0.0-SNAPSHOT.jar'
|
||||
]
|
||||
|
||||
def serviceCheckboxes = [
|
||||
'gateway': 'SERVICE_GATEWAY',
|
||||
'auth': 'SERVICE_AUTH',
|
||||
'iam': 'SERVICE_IAM',
|
||||
'firstleg': 'SERVICE_FIRSTLEG',
|
||||
'order': 'SERVICE_ORDER',
|
||||
'warehouse': 'SERVICE_WAREHOUSE',
|
||||
'file': 'SERVICE_FILE',
|
||||
'print': 'SERVICE_PRINT',
|
||||
'integration-service': 'SERVICE_INTEGRATION',
|
||||
'event-bridge-service': 'SERVICE_EVENT_BRIDGE',
|
||||
'audit-service': 'SERVICE_AUDIT'
|
||||
]
|
||||
|
||||
def commonPaths = [
|
||||
'pom.xml', 'platform-bom/', 'common-core/', 'common-web/', 'common-security/',
|
||||
'common-openapi/', 'common-audit/', 'common-event-contract/', 'Jenkinsfile', 'deploy/'
|
||||
@@ -38,12 +52,23 @@ pipeline {
|
||||
}
|
||||
|
||||
parameters {
|
||||
choice(name: 'BUILD_MODE', choices: ['AUTO', 'SELECT', 'ALL'], description: 'AUTO 按 Git 变更识别;SELECT 手工指定;ALL 构建全部服务')
|
||||
string(name: 'SERVICE', defaultValue: 'gateway', description: 'SELECT 模式填写服务名,多个服务用英文逗号分隔')
|
||||
choice(name: 'BUILD_MODE', choices: ['AUTO', 'SELECT', 'ALL'], description: 'AUTO 按 Git 变更识别;SELECT 勾选服务;ALL 构建全部服务')
|
||||
booleanParam(name: 'SERVICE_GATEWAY', defaultValue: false, description: 'Gateway 网关服务(gateway)')
|
||||
booleanParam(name: 'SERVICE_AUTH', defaultValue: false, description: '统一认证服务(auth)')
|
||||
booleanParam(name: 'SERVICE_IAM', defaultValue: false, description: '租户与权限服务(iam)')
|
||||
booleanParam(name: 'SERVICE_FIRSTLEG', defaultValue: false, description: '头程履约服务(firstleg)')
|
||||
booleanParam(name: 'SERVICE_ORDER', defaultValue: false, description: '订单服务(order)')
|
||||
booleanParam(name: 'SERVICE_WAREHOUSE', defaultValue: false, description: '仓库与往来单位服务(warehouse)')
|
||||
booleanParam(name: 'SERVICE_FILE', defaultValue: false, description: '文件中心(file)')
|
||||
booleanParam(name: 'SERVICE_PRINT', defaultValue: false, description: '打印服务(print)')
|
||||
booleanParam(name: 'SERVICE_INTEGRATION', defaultValue: false, description: '第三方集成服务(integration-service)')
|
||||
booleanParam(name: 'SERVICE_EVENT_BRIDGE', defaultValue: false, description: '跨区域事件桥(event-bridge-service)')
|
||||
booleanParam(name: 'SERVICE_AUDIT', defaultValue: false, description: '审计服务(audit-service)')
|
||||
choice(name: 'ENVIRONMENT', choices: ['test', 'staging', 'production'], description: '部署环境')
|
||||
booleanParam(name: 'DEPLOY', defaultValue: false, description: '构建成功后是否部署')
|
||||
booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: '是否跳过测试;生产构建不建议勾选')
|
||||
string(name: 'IMAGE_REPOSITORY', defaultValue: 'registry.example.com/your-group/baiyue-firstleg', description: 'GitLab Container Registry 项目地址')
|
||||
string(name: 'DOCKER_BASE_IMAGE', defaultValue: 'docker.m.daocloud.io/library/eclipse-temurin:17-jre-alpine', description: 'Java 17 基础镜像;默认使用国内镜像代理')
|
||||
}
|
||||
|
||||
environment {
|
||||
@@ -58,7 +83,12 @@ pipeline {
|
||||
if (params.BUILD_MODE == 'ALL') {
|
||||
selected = serviceModules
|
||||
} else if (params.BUILD_MODE == 'SELECT') {
|
||||
selected = params.SERVICE.split(',').collect { it.trim() }.findAll { it }
|
||||
selected = serviceModules.findAll { service ->
|
||||
params[serviceCheckboxes[service]] == true
|
||||
}
|
||||
if (!selected) {
|
||||
error('SELECT 模式至少需要勾选一个服务')
|
||||
}
|
||||
} else {
|
||||
String base = env.GIT_PREVIOUS_SUCCESSFUL_COMMIT?.trim()
|
||||
if (!base || sh(script: "git cat-file -e ${base}^{commit} 2>/dev/null", returnStatus: true) != 0) {
|
||||
@@ -117,7 +147,7 @@ pipeline {
|
||||
sh 'printf %s "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin "' + registryHost + '"'
|
||||
env.SELECTED_SERVICES.split(',').each { service ->
|
||||
String image = "${params.IMAGE_REPOSITORY}/${service}:${env.IMAGE_TAG}"
|
||||
sh "docker build -f deploy/docker/Dockerfile --build-arg JAR_FILE=${serviceJars[service]} -t ${image} ."
|
||||
sh "docker build -f deploy/docker/Dockerfile --build-arg BASE_IMAGE=${params.DOCKER_BASE_IMAGE} --build-arg JAR_FILE=${serviceJars[service]} -t ${image} ."
|
||||
sh "docker push ${image}"
|
||||
}
|
||||
sh "docker logout ${registryHost} || true"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
FROM eclipse-temurin:17-jre-alpine
|
||||
ARG BASE_IMAGE=docker.m.daocloud.io/library/eclipse-temurin:17-jre-alpine
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
RUN apk add --no-cache curl \
|
||||
&& addgroup -S app \
|
||||
|
||||
@@ -45,11 +45,12 @@ GitLab 仓库拉取如果不是由 Jenkins GitLab 集成统一授权,还需单
|
||||
| 参数 | 推荐值 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `BUILD_MODE` | `AUTO` | 自动分析上次成功构建之后的 Git 变更 |
|
||||
| `SERVICE` | 按需 | `SELECT` 时填写,如 `order,warehouse` |
|
||||
| `SERVICE_*` 复选框 | 按需 | `SELECT` 时勾选一个或多个服务,如订单和仓库 |
|
||||
| `ENVIRONMENT` | `test` | 可选 `test`、`staging`、`production` |
|
||||
| `DEPLOY` | 测试环境勾选 | 是否在镜像推送后执行部署 |
|
||||
| `SKIP_TESTS` | 不勾选 | 临时调试才跳过测试 |
|
||||
| `IMAGE_REPOSITORY` | GitLab 项目镜像地址 | 示例 `gitlab.example.com/logistics/baiyue-firstleg` |
|
||||
| `DOCKER_BASE_IMAGE` | 保持默认 | 默认通过国内镜像代理拉取 Java 17 运行时,也可替换为企业内部镜像地址 |
|
||||
|
||||
公共模块、根 POM 或 Dockerfile 变化会构建全部 11 个服务。仅 `order/**` 变化时执行:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user