From 958dd713224524dbde472f18298a4d1ddb8ff318 Mon Sep 17 00:00:00 2001
From: chengling <chengling@hbbohua.com>
Date: Fri, 22 Apr 2022 14:11:11 +0800
Subject: [PATCH] master5

---
 Jenkinsfile |   45 ++++++++++++++++++++++++++++++---------------
 1 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index e8f9211..5fbfd58 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -30,14 +30,14 @@
 
             }
         }
-        stage('testMaven') {
-            steps {
+        //stage('testMaven') {
+            //steps {
 
-                sh 'mvn clean test -U'
-                junit allowEmptyResults: true, keepLongStdio: true, skipPublishingChecks: true, testResults: 'target/surefire-reports/*.xml'
+                //sh 'mvn clean test -U'
+                //junit allowEmptyResults: true, keepLongStdio: true, skipPublishingChecks: true, testResults: 'target/surefire-reports/*.xml'
 
-            }
-        }
+            //}
+        //}
         stage('testFunction') {
             steps {
                 sh 'echo test'
@@ -51,12 +51,9 @@
                     ####maven编译部署#####
                     ##mvn clean package -U
                     ##处理结果包
-                    old_version=\$(find . -iname "\${project_name}.java"| xargs sed -nr 's/^[^0-9]*(([0-9]+\\.)*[0-9]+).*;/\\1/p\')
-                    if [ "\$old_version_all" =~ "-" ];then
-                        echo "包含"
-                    else
-                        echo "不包含"
-                    fi
+                    versionFile=\$(find . -iname "${project_name}.java")
+                    str="-"
+                    old_version_all=\$(cat \$versionFile | sed -nr \'s/^[^0-9]*"([^"]+)".*;/\\1/p\')
                     echo "old_version_all \$old_version_all"
                     echo "project_name \$project_name"
                     dir_name=\${project_name}"-"\$old_version_all
@@ -68,7 +65,24 @@
                 '''
             }
         }
-        stage('version add') {
+
+        stage('master version add') {
+            when {
+                not {
+                    allOf {
+                       changeset "**/${project_name}.java"
+                    }
+                }
+                branch 'master'
+            }
+            steps {
+                //http(s)的git链接使用帐号密码,ssh使用 keyFileVariable: 'SSH_KEY'
+                echo "todo version add"
+                versionAddCom("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
+                }
+        }
+
+        stage('version add develop') {
             when {
                 //版本号自动添加逻辑需同时符合下列触发条件:
                 //1. 不能在master分支触发
@@ -86,13 +100,14 @@
                     not {
                         changeset "**/${project_name}.java"
                     }
-
+                    branch 'develop'
                 }
             }
             steps {
-                versionAddTest("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
+                versionAddCom("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
             }
         }
+
         stage('deploy') {
             when { branch 'master' }
             steps {

--
Gitblit v1.9.1