Tuesday, December 18, 2018

Inject git last commit id to SpringBoot project

1) Add git-commit-id-plugin in pom.xml

  <build>
  <plugins>
  <plugin>
      <groupId>pl.project13.maven</groupId>
      <artifactId>git-commit-id-plugin</artifactId>
      <executions>
          <execution>
              <goals>
                  <goal>revision</goal>
              </goals>
          </execution>
      </executions>
      <configuration>
          <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
          <includeOnlyProperties>
              <includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
          </includeOnlyProperties>
      </configuration>
  </plugin>
  ...
  </plugins>
  </build>


2) Get the value via Thymeleaf

   <head th:with="abbrev=${@environment.getProperty('git.commit.id.abbrev')}">

No comments:

Post a Comment

CSP on Apache

To add CSP to root if sort of funny. The following will NOT work for most cases !!     <LocationMatch "^/$">        Header s...