From 7979ac13cd60f7b2285c4a7ea0879478055e6842 Mon Sep 17 00:00:00 2001
From: wangzilun <964606955@qq.com>
Date: Tue, 18 Jan 2022 15:38:44 +0800
Subject: [PATCH] 新增版本号脚本测试
---
Jenkinsfile | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 61da019..3060362 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -10,8 +10,11 @@
}
options {
//给日志加上时间错, 需安装 Timestamper 插件
+ //mvn test surefire-report:report
timestamps()
ansiColor('xterm')
+ //丢弃旧的构建前两个为发布包保留天数(比此早的发布包将被删除,但构建的日志、操作历史、报告等将被保留)和构建个数
+ buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '10')
}
stages {
@@ -27,12 +30,20 @@
}
}
- stage('test') {
+ stage('testMaven') {
+ steps {
+
+ sh 'mvn clean test -U'
+ junit allowEmptyResults: true, keepLongStdio: true, skipPublishingChecks: true, testResults: 'target/surefire-reports/*.xml'
+
+ }
+ }
+ stage('testFunction') {
steps {
sh '''
#定义颜色的变量
- RED_COLOR='\\E[1;31m' #红
+ RED_COLOR='\\033[1;31m' #红
GREEN_COLOR='\\E[1;32m' #绿
YELOW_COLOR='\\E[1;33m' #黄
BLUE_COLOR='\\E[1;34m' #蓝
@@ -61,7 +72,7 @@
echo ----需注意!----- && \$SETCOLOR_WARNING
echo ----正常的!----- && \$SETCOLOR_NORMAL
- echo "BRANCH ${GIT_BRANCH}"
+ echo -e "\${GREEN_COLOR}BRANCH ${GIT_BRANCH}\${RES}"
printenv
'''
test("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
@@ -69,6 +80,10 @@
}
stage('version add') {
when {
+ //版本号自动添加逻辑需同时符合下列触发条件:
+ //1. 不能在master分支触发
+ //2. 有任意浏览器页面资源文件修改
+ //3. 不包含[项目名.java]文件的修改
allOf {
not {
branch 'master'
@@ -86,10 +101,9 @@
}
}
}
- steps{
- echo "todo add version"
+ steps {
+ versionAddTest("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
}
-
}
stage('deploy') {
when { branch 'master' }
--
Gitblit v1.9.1