From 14cf68d91a7369836e4048a74f6ad72151100a7b Mon Sep 17 00:00:00 2001
From: wangzilun <964606955@qq.com>
Date: Tue, 08 Mar 2022 16:47:23 +0800
Subject: [PATCH] 添加一个类

---
 Jenkinsfile |   60 +++++++++++++++++++-----------------------------------------
 1 files changed, 19 insertions(+), 41 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index fcc5547..f184a85 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -30,17 +30,23 @@
 
             }
         }
-        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'
+                sh '''
+                    commit_name="\$(git show -s --pretty=%an)"
+                    commit_message="\$(git show -s --pretty=%s)"
+                    echo "\$commit_name"
+                    echo "\$commit_message"
+                    printenv
+                '''
             }
         }
 
@@ -51,12 +57,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
@@ -66,31 +69,6 @@
                     ##cp *.war \$dir_name
                     ##zip -r "\$dir_name.zip" \$dir_name
                 '''
-            }
-        }
-        stage('version add master') {
-            when {
-                //版本号自动添加逻辑需同时符合下列触发条件:
-                //1. 不能在master分支触发
-                //2. 有任意浏览器页面资源文件修改
-                //3. 不包含[项目名.java]文件的修改
-                allOf {
-                    anyOf {
-                        changeset "**/*.js"
-                        changeset "**/*.css"
-                        changeset "**/*.html"
-                        changeset "**/*.xhtml"
-                        changeset "**/*.jpg"
-                        changeset "**/*.png"
-                    }
-                    not {
-                        changeset "**/${project_name}.java"
-                    }
-                    branch 'master'
-                }
-            }
-            steps {
-                versionAddDevelop("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
             }
         }
 
@@ -106,11 +84,11 @@
             steps {
                 //http(s)的git链接使用帐号密码,ssh使用 keyFileVariable: 'SSH_KEY'
                 echo "todo version add"
-                versionAddDevelop("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
+                versionAddCom("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
                 }
         }
 
-        stage('version add master') {
+        stage('version add develop') {
             when {
                 //版本号自动添加逻辑需同时符合下列触发条件:
                 //1. 不能在master分支触发
@@ -132,7 +110,7 @@
                 }
             }
             steps {
-                versionAddDevelop("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
+                versionAddCom("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
             }
         }
 

--
Gitblit v1.9.1