From d10f033d23712bad0f5ef76774642f1d34b19e82 Mon Sep 17 00:00:00 2001
From: wangzilun <964606955@qq.com>
Date: Tue, 18 Jan 2022 15:21:13 +0800
Subject: [PATCH] 新增版本号脚本测试
---
Jenkinsfile | 10 ++++++----
test.js | 3 ++-
pom.xml | 3 +++
src/main/java/git_study.java | 18 ++++++++++++++++++
4 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index c925415..3060362 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -80,6 +80,10 @@
}
stage('version add') {
when {
+ //版本号自动添加逻辑需同时符合下列触发条件:
+ //1. 不能在master分支触发
+ //2. 有任意浏览器页面资源文件修改
+ //3. 不包含[项目名.java]文件的修改
allOf {
not {
branch 'master'
@@ -97,11 +101,9 @@
}
}
}
- steps{
- echo "todo add version"
+ steps {
+ versionAddTest("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}")
}
-
-
}
stage('deploy') {
when { branch 'master' }
diff --git a/pom.xml b/pom.xml
index 704b7f7..1969ba2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,9 @@
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
+ <!--当前项目版本号-->
+ <revision>1.8.0-SNAPSHOT</revision>
+ <maven.deploy.skip>true</maven.deploy.skip>
</properties>
<build>
<plugins>
diff --git a/src/main/java/git_study.java b/src/main/java/git_study.java
new file mode 100644
index 0000000..5219fb8
--- /dev/null
+++ b/src/main/java/git_study.java
@@ -0,0 +1,18 @@
+/**
+ * 测试项目<br>
+ */
+public class git_study {
+ /**
+ * 保证每次打包发现场部署时增长(目前仅增长末位 +1)
+ */
+ String version = "1.8.0-SNAPSHOT-1";
+
+ /**
+ * 获取版本号。可用于前端资源引用版本化,解决浏览器缓存问题。
+ *
+ * @return 版本号
+ */
+ public String getVersion() {
+ return version;
+ }
+}
diff --git a/test.js b/test.js
index 6bbc9be..4ead320 100644
--- a/test.js
+++ b/test.js
@@ -30,4 +30,5 @@
detached1
detached2
detached3
- detached4
\ No newline at end of file
+ detached4
+111
\ No newline at end of file
--
Gitblit v1.9.1