-
Notifications
You must be signed in to change notification settings - Fork 0
/
GitCustomRestControllerEndPoint.java
41 lines (32 loc) · 1.24 KB
/
GitCustomRestControllerEndPoint.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package gary.framework.gitinfoactuator.endpoint;
import gary.framework.gitinfoactuator.model.GitInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
@Component
@ConditionalOnProperty(name = "project.show.git.version", havingValue = "true")
@RestControllerEndpoint(id = "custom-info")
public class GitCustomRestControllerEndPoint {
@Value("${git.branch:#{null}}")
private String branch;
@Value("${git.commit.id:#{null}}")
private String commitId;
@Value("${git.commit.time:#{null}}")
private String commitTime;
@Value("${git.tags:#{null}}")
private String tags;
@Value("${git.commit.message.short:#{null}}")
private String message;
@GetMapping("/git/detail")
public GitInfo getDetailInfo() {
return GitInfo.builder()
.branch(branch)
.commitId(commitId)
.commitTime(commitTime)
.tags(tags)
.message(message)
.build();
}
}