wangzilun
2022-03-08 f8cd8b1d6e2120e24230d23c7bd2142a93848e71
Jenkinsfile
@@ -30,17 +30,22 @@
            }
        }
        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"
                '''
            }
        }
@@ -52,14 +57,10 @@
                    ##mvn clean package -U
                    ##处理结果包
                    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"
                    if [ ["\$old_version_all" =~ "-"] ];then
                        echo "包含"
                    else
                        echo "不包含"
                    fi
                    dir_name=\${project_name}"-"\$old_version_all
                    echo "dir_name \$dir_name"
                    ##cd target
@@ -82,11 +83,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分支触发
@@ -108,7 +109,7 @@
                }
            }
            steps {
                versionAddDevelop("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
                versionAddCom("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
            }
        }