Răsfoiți Sursa

流水线优化 - 最后推送到Harbor 制品库

dujian 2 săptămâni în urmă
părinte
comite
04b4f16342

+ 32 - 6
docs/jenkins/Jenkinsfile-uat-build-deploy.groovy

@@ -8,6 +8,24 @@
  *   39.105.153.68/alien_cloud/gateway:uat-build-<BUILD_NUMBER>
  *   39.105.153.68/alien_cloud/gateway:uat-build-<BUILD_NUMBER>
  * Production promote jobs use SOURCE_TAG=uat-build-<same number>.
  * Production promote jobs use SOURCE_TAG=uat-build-<same number>.
  */
  */
+
+/** HARBOR_PUSH_SCOPE: all-java-services | <repo>-only */
+def filterHarborPushScope(List allServices, String scope) {
+    def s = (scope ?: 'all-java-services').trim()
+    if (s == 'all-java-services') {
+        return allServices
+    }
+    if (s.endsWith('-only')) {
+        def repo = s.substring(0, s.length() - '-only'.length())
+        def picked = allServices.findAll { it.repo == repo }
+        if (picked.isEmpty()) {
+            error("Unknown HARBOR_PUSH_SCOPE: ${scope}")
+        }
+        return picked
+    }
+    error("Unknown HARBOR_PUSH_SCOPE: ${scope}")
+}
+
 pipeline {
 pipeline {
     agent any
     agent any
 
 
@@ -33,8 +51,17 @@ pipeline {
         )
         )
         choice(
         choice(
                 name: 'HARBOR_PUSH_SCOPE',
                 name: 'HARBOR_PUSH_SCOPE',
-                choices: ['gateway-only', 'all-java-services'],
-                description: 'Only used when PUSH_TO_HARBOR=true'
+                choices: [
+                        'all-java-services',
+                        'gateway-only',
+                        'store-only',
+                        'second-only',
+                        'store-platform-only',
+                        'lawyer-only',
+                        'job-only',
+                        'dining-only',
+                ],
+                description: 'Only when PUSH_TO_HARBOR=true; default=all seven; *-only=one service'
         )
         )
         string(name: 'HARBOR_REGISTRY', defaultValue: '39.105.153.68', trim: true)
         string(name: 'HARBOR_REGISTRY', defaultValue: '39.105.153.68', trim: true)
         string(name: 'HARBOR_PROJECT', defaultValue: 'alien_cloud', trim: true)
         string(name: 'HARBOR_PROJECT', defaultValue: 'alien_cloud', trim: true)
@@ -161,7 +188,7 @@ pipeline {
                     def baseImage = "${reg}/${proj}/base/openjdk8-ffmpeg:v1"
                     def baseImage = "${reg}/${proj}/base/openjdk8-ffmpeg:v1"
                     def dockerfile = env.DOCKERFILE_JAVA
                     def dockerfile = env.DOCKERFILE_JAVA
 
 
-                    def harborServices = [
+                    def allHarborServices = [
                             [module: 'alien-gateway',        repo: 'gateway',        port: '8000',  withLib: false],
                             [module: 'alien-gateway',        repo: 'gateway',        port: '8000',  withLib: false],
                             [module: 'alien-store',          repo: 'store',          port: '50014', withLib: true],
                             [module: 'alien-store',          repo: 'store',          port: '50014', withLib: true],
                             [module: 'alien-second',         repo: 'second',         port: '50015', withLib: false],
                             [module: 'alien-second',         repo: 'second',         port: '50015', withLib: false],
@@ -170,9 +197,8 @@ pipeline {
                             [module: 'alien-job',            repo: 'job',            port: '50108', withLib: false],
                             [module: 'alien-job',            repo: 'job',            port: '50108', withLib: false],
                             [module: 'alien-dining',         repo: 'dining',         port: '50019', withLib: false],
                             [module: 'alien-dining',         repo: 'dining',         port: '50019', withLib: false],
                     ]
                     ]
-                    if (params.HARBOR_PUSH_SCOPE == 'gateway-only') {
-                        harborServices = harborServices.findAll { it.repo == 'gateway' }
-                    }
+                    def harborServices = filterHarborPushScope(allHarborServices, params.HARBOR_PUSH_SCOPE)
+                    echo ">>> HARBOR_PUSH_SCOPE=${params.HARBOR_PUSH_SCOPE} repos=${harborServices*.repo.join(',')}"
 
 
                     withCredentials([usernamePassword(
                     withCredentials([usernamePassword(
                             credentialsId: env.HARBOR_CREDENTIALS,
                             credentialsId: env.HARBOR_CREDENTIALS,

+ 2 - 2
docs/jenkins/README-UAT-HARBOR-PUSH.md

@@ -92,7 +92,7 @@ echo '<TOKEN>' | docker login 39.105.153.68 -u 'robot$alien_cloud+jenkins-k8s' -
 | `GIT_BRANCH` | `uat-20260202` |
 | `GIT_BRANCH` | `uat-20260202` |
 | `FORCE_UPDATE` | 按需 |
 | `FORCE_UPDATE` | 按需 |
 | **`PUSH_TO_HARBOR`** | **`true`** |
 | **`PUSH_TO_HARBOR`** | **`true`** |
-| **`HARBOR_PUSH_SCOPE`** | **`gateway-only`** |
+| **`HARBOR_PUSH_SCOPE`** | 默认 **`all-java-services`**;试单个服务选 **`gateway-only`** |
 | `HARBOR_REGISTRY` | `39.105.153.68` |
 | `HARBOR_REGISTRY` | `39.105.153.68` |
 | `HARBOR_PROJECT` | `alien_cloud` |
 | `HARBOR_PROJECT` | `alien_cloud` |
 
 
@@ -137,7 +137,7 @@ curl -s -u 'robot$alien_cloud+jenkins-k8s:<TOKEN>' \
 | 参数 | 说明 |
 | 参数 | 说明 |
 |------|------|
 |------|------|
 | `PUSH_TO_HARBOR` | `false`=保持旧行为,只 jar 部署;`true`=增加 Harbor push |
 | `PUSH_TO_HARBOR` | `false`=保持旧行为,只 jar 部署;`true`=增加 Harbor push |
-| `HARBOR_PUSH_SCOPE` | `gateway-only` 只推 gateway;`all-java-services` 推七个服务(Maven 须全部打包成功) |
+| `HARBOR_PUSH_SCOPE` | 默认 **`all-java-services`**(七个);**`gateway-only`** 等只推一个;Maven 须对所选模块打出 jar |
 | `UAT_HARBOR_IMAGE_TAG` | 自动 `uat-build-${BUILD_NUMBER}`,无需手填 |
 | `UAT_HARBOR_IMAGE_TAG` | 自动 `uat-build-${BUILD_NUMBER}`,无需手填 |
 
 
 ---
 ---