Skip to content

Commit 0923409

Browse files
committed
Merge branch 'release/v1.0.3'
2 parents 96f59c6 + 3ed6ab7 commit 0923409

File tree

7 files changed

+1007
-769
lines changed

7 files changed

+1007
-769
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
${{ secrets.DOCKERHUB_USERNAME }}/veritas-assessment-tool:latest
7070
${{ secrets.DOCKERHUB_USERNAME }}/veritas-assessment-tool:v1
7171
${{ secrets.DOCKERHUB_USERNAME }}/veritas-assessment-tool:v1.0
72-
${{ secrets.DOCKERHUB_USERNAME }}/veritas-assessment-tool:v1.0.2
72+
${{ secrets.DOCKERHUB_USERNAME }}/veritas-assessment-tool:v1.0.3
7373
7474
7575
- name: Move cache

bin/tool.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@ function print_help() {
6060
}
6161

6262
function clear_cache() {
63-
touch 'file/db/.clear_cache'
63+
touch $CLEAR_CACHE_FILE
6464
}
6565

6666
cd "$(dirname $0)" || exit
6767
cd .. || exit
6868

69+
# sqlite database file
6970
SQLITE_FILE='file/db/sqlite.db'
7071

72+
# If this file exists then the Java application will clear the cache and delete this file.
73+
CLEAR_CACHE_FILE='file/db/.clear_cache'
74+
7175
if [[ $# -eq 0 ]]; then
7276
print_help;
7377
exit 1;

docker/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/bash
2-
set -x
2+
33
cd $(dirname $0)/.. || exit
44

55
if [ "$(ls config/)" == "" ]; then

pom.xml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>org.veritas</groupId>
1212
<artifactId>assessment-tool</artifactId>
13-
<version>1.0.2</version>
13+
<version>1.0.3</version>
1414
<name>assessment</name>
1515
<description>Assessment tool of veritas.</description>
1616
<properties>
@@ -269,6 +269,36 @@
269269
<version>3.9.1</version>
270270
</plugin>
271271

272+
<plugin>
273+
<groupId>pl.project13.maven</groupId>
274+
<artifactId>git-commit-id-plugin</artifactId>
275+
<version>4.0.5</version>
276+
<executions>
277+
<execution>
278+
<id>get-the-git-info</id>
279+
<goals>
280+
<goal>revision</goal>
281+
</goals>
282+
<phase>initialize</phase>
283+
</execution>
284+
</executions>
285+
<configuration>
286+
<format>json</format>
287+
<generateGitPropertiesFile>true</generateGitPropertiesFile>
288+
<generateGitPropertiesFilename>
289+
${project.build.outputDirectory}/git-version.json
290+
</generateGitPropertiesFilename>
291+
<!--
292+
<includeOnlyProperties>
293+
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
294+
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
295+
</includeOnlyProperties>
296+
-->
297+
<commitIdGenerationMode>full</commitIdGenerationMode>
298+
<offline>true</offline>
299+
</configuration>
300+
</plugin>
301+
272302
</plugins>
273303
<pluginManagement>
274304
<plugins>

src/main/java/org/veritas/assessment/biz/controller/admin/AdminSystemController.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@
1818

1919
import io.swagger.v3.oas.annotations.Operation;
2020
import lombok.extern.slf4j.Slf4j;
21+
import org.apache.commons.io.IOUtils;
22+
import org.apache.commons.lang3.StringUtils;
2123
import org.springframework.beans.factory.annotation.Autowired;
24+
import org.springframework.core.io.ClassPathResource;
2225
import org.springframework.security.access.prepost.PreAuthorize;
2326
import org.springframework.web.bind.annotation.GetMapping;
2427
import org.springframework.web.bind.annotation.PostMapping;
2528
import org.springframework.web.bind.annotation.RequestBody;
2629
import org.springframework.web.bind.annotation.RequestMapping;
30+
import org.springframework.web.bind.annotation.RequestMethod;
2731
import org.springframework.web.bind.annotation.RestController;
32+
import org.veritas.assessment.common.exception.NotFoundException;
2833
import org.veritas.assessment.system.service.SystemConfigService;
2934

35+
import java.io.IOException;
36+
import java.io.InputStream;
37+
import java.nio.charset.StandardCharsets;
3038
import java.util.Map;
3139

3240
@RestController
@@ -67,4 +75,27 @@ public void updateConfig(@RequestBody Map<String, String> configMap) {
6775
}
6876
}
6977

78+
private static final String GIT_VERSION_FILE_PATH = "/git-version.json";
79+
private static final String versionInfo;
80+
81+
static {
82+
String json;
83+
try (InputStream is = new ClassPathResource(GIT_VERSION_FILE_PATH).getInputStream()) {
84+
json = IOUtils.toString(is, StandardCharsets.UTF_8);
85+
} catch (IOException exception) {
86+
log.warn("can not read git version info file[{}].", GIT_VERSION_FILE_PATH,
87+
exception);
88+
json = "{}";
89+
}
90+
versionInfo = json;
91+
}
92+
93+
@RequestMapping(path = "/version", method = RequestMethod.GET,
94+
produces = "application/json; charset=UTF-8")
95+
public String getGitVersion() {
96+
if (StringUtils.isEmpty(versionInfo)) {
97+
throw new NotFoundException("Not found version information.");
98+
}
99+
return versionInfo;
100+
}
70101
}

0 commit comments

Comments
 (0)