print buildNumber

This commit is contained in:
dzj 2024-08-01 08:13:31 +08:00
parent f6578802ff
commit ae89854b88
2 changed files with 16 additions and 6 deletions

20
pom.xml
View File

@ -51,7 +51,6 @@
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}##${buildNumber}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -63,7 +62,7 @@
</goals> </goals>
<configuration> <configuration>
<additionalProperties> <additionalProperties>
<build.timestamp>${buildNumber}</build.timestamp> <buildNumber>${buildNumber}</buildNumber>
<java.version>${java.version}</java.version> <java.version>${java.version}</java.version>
</additionalProperties> </additionalProperties>
</configuration> </configuration>
@ -100,7 +99,7 @@
<configuration> <configuration>
<name>buildNumber</name> <name>buildNumber</name>
<pattern>yyyyMMdd-HHmmss</pattern> <pattern>yyyyMMdd-HHmmss</pattern>
<timeZone>GMT+08:00</timeZone> <timeZone>GMT+8</timeZone>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
@ -109,12 +108,23 @@
</build> </build>
<profiles> <profiles>
<profile>
<id>buildNumber</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<finalName>${project.artifactId}##${buildNumber}</finalName>
</build>
</profile>
<profile> <profile>
<id>build-docker-image</id> <id>build-docker-image</id>
<activation> <activation>
<activeByDefault>false</activeByDefault> <activeByDefault>false</activeByDefault>
</activation> </activation>
<build> <build>
<finalName>${project.artifactId}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>com.google.cloud.tools</groupId> <groupId>com.google.cloud.tools</groupId>
@ -131,7 +141,7 @@
<to> <to>
<image>svn.youshengyun.com:9923/${project.artifactId}-jib</image> <image>svn.youshengyun.com:9923/${project.artifactId}-jib</image>
<tags> <tags>
<tag>${project.version}</tag> <tag>${project.version}-${buildNumber}</tag>
<tag>latest</tag> <tag>latest</tag>
</tags> </tags>
<auth> <auth>
@ -142,7 +152,7 @@
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<phase>install</phase> <phase>package</phase>
<goals> <goals>
<goal>build</goal> <goal>build</goal>
</goals> </goals>

View File

@ -14,6 +14,6 @@ public class MainController {
@GetMapping({ "", "/" }) @GetMapping({ "", "/" })
public String index(HttpServletRequest request) { public String index(HttpServletRequest request) {
return "hello demo-tomcat " + buildProperties.get("build.timestamp"); return "hello demo-tomcat! buildNumber = " + buildProperties.get("buildNumber");
} }
} }