Explorar el Código

流水线优化

dujian hace 1 día
padre
commit
e849f2e566
Se han modificado 2 ficheros con 15 adiciones y 2 borrados
  1. 13 2
      docs/jenkins/uat/Jenkinsfile
  2. 2 0
      docs/jenkins/uat/README.md

+ 13 - 2
docs/jenkins/uat/Jenkinsfile

@@ -10,6 +10,17 @@
  * New image is pushed only as uat-latest. Prod promote: SOURCE_TAG=uat-latest.
  */
 
+/** Normalize GIT_BRANCH: uat-20260202 (not origin/uat-20260202 or refs/heads/...) */
+def normalizeGitBranch(String raw) {
+    def b = (raw ?: 'uat-20260202').trim()
+    if (!b) {
+        return 'uat-20260202'
+    }
+    b = b.replaceFirst('^refs/heads/', '')
+    b = b.replaceFirst('^origin/', '')
+    return b
+}
+
 /** HARBOR_PUSH_SCOPE: all-java-services | <repo>-only */
 def filterHarborPushScope(List allServices, String scope) {
     def s = (scope ?: 'all-java-services').trim()
@@ -216,12 +227,12 @@ pipeline {
         stage('Checkout') {
             steps {
                 script {
-                    def branch = (params.GIT_BRANCH ?: 'uat-20260202').trim()
+                    def branch = normalizeGitBranch(params.GIT_BRANCH)
                     if (!branch) {
                         error('GIT_BRANCH is required')
                     }
                     env.GIT_BRANCH = branch
-                    echo ">>> Checkout branch: ${env.GIT_BRANCH}"
+                    echo ">>> Checkout branch: ${env.GIT_BRANCH} (use branch name only, e.g. uat-20260202)"
                     git branch: "${env.GIT_BRANCH}",
                             credentialsId: "${env.GIT_CREDENTIALS}",
                             url: "${env.GIT_URL}"

+ 2 - 0
docs/jenkins/uat/README.md

@@ -12,6 +12,8 @@
 
 保存后 **Build with Parameters 构建一次**,加载新参数(`HARBOR_PUSH_PARALLEL`、`FORCE_UPDATE` 默认 false 等)。
 
+**`GIT_BRANCH` 填分支名即可**,例如 `uat-20260202`;不要填 `origin/uat-20260202`(会报 `Couldn't find any revision to build`)。脚本已自动去掉误填的 `origin/` 前缀。
+
 ## 与旧内嵌脚本的区别
 
 | 项 | 旧内嵌脚本 | 本脚本 |