Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Include Git revision information in the startup console for Deposit S…
Browse files Browse the repository at this point in the history
…ervices (#123)

* Generate git commit information to be used at runtime.

* Update Maven POM versions to be congruent with Docker image versioning.
  • Loading branch information
emetsger authored Jun 22, 2018
1 parent 93e74a8 commit 390aec0
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 17 deletions.
2 changes: 1 addition & 1 deletion builder-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>builder-api</artifactId>
Expand Down
22 changes: 21 additions & 1 deletion deposit-messaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>deposit-messaging</artifactId>
Expand Down Expand Up @@ -96,6 +96,26 @@

<plugins>

<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<abbrevLength>8</abbrevLength>
</configuration>
<executions>
<execution>
<id>gitproperties</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Properties;


/**
Expand All @@ -40,14 +43,45 @@ public class DepositApp {

private static final Logger LOG = LoggerFactory.getLogger(DepositApp.class);

private static final String GIT_BUILD_VERSION_KEY = "git.build.version";

private static final String GIT_COMMIT_HASH_KEY = "git.commit.id.abbrev";

private static final String GIT_COMMIT_TIME_KEY = "git.commit.time";

private static final String GIT_DIRTY_FLAG = "git.dirty";

private static final String GIT_BRANCH = "git.branch";

private String fcrepoUser;

private String fcrepoPass;

private String fcrepoBaseUrl;

private static final String GIT_PROPERTIES_RESOURCE_PATH = "/git.properties";

public static void main(String[] args) {
LOG.info(">>>> Starting DepositService");

URL gitPropertiesResource = DepositApp.class.getResource(GIT_PROPERTIES_RESOURCE_PATH);
if (gitPropertiesResource == null) {
LOG.info(">>>> Starting DepositServices (no Git commit information available)");
} else {
Properties gitProperties = new Properties();
try {
gitProperties.load(gitPropertiesResource.openStream());
boolean isDirty = Boolean.valueOf(gitProperties.getProperty(GIT_DIRTY_FLAG));

LOG.info(">>>> Starting DepositServices (version: {} branch: {} commit: {} commit date: {})",
gitProperties.get(GIT_BUILD_VERSION_KEY), gitProperties.get(GIT_BRANCH), gitProperties.get(GIT_COMMIT_HASH_KEY), gitProperties.getProperty(GIT_COMMIT_TIME_KEY));

if (isDirty) {
LOG.warn(">>>> ** Deposit Services was compiled from a Git repository with uncommitted changes! **");
}
} catch (IOException e) {
LOG.warn(">>>> Starting DepositService (" + GIT_PROPERTIES_RESOURCE_PATH + " could not be parsed: " + e.getMessage() + ")");
}
}

if (args.length < 1 || args[0] == null) {
throw new IllegalArgumentException("Requires at least one argument!");
Expand Down
2 changes: 1 addition & 1 deletion deposit-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>deposit-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion dspace-mets-assembler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>dspace-mets-assembler</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion fedora-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>fedora-builder</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-assembler-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-assembler-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-cli</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-ftp-transport/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-ftp-transport</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-integration</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-native-assembler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-native-assembler</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-submission-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-submission-engine</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-transport-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-transport-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>nihms-util</artifactId>
Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>NIH Package and Submission Parent Project</name>

Expand Down Expand Up @@ -80,6 +80,7 @@
<maven.remote-resources.plugin.version>1.5</maven.remote-resources.plugin.version>
<codehaus.build-helper.plugin.version>1.10</codehaus.build-helper.plugin.version>
<fabric8.docker.maven.plugin.version>0.24.0</fabric8.docker.maven.plugin.version>
<git-commit-plugin.version>2.2.4</git-commit-plugin.version>
<slf4j.version>1.7.25</slf4j.version>
<logback-classic.version>1.2.3</logback-classic.version>
<junit.version>4.12</junit.version>
Expand Down Expand Up @@ -117,6 +118,12 @@

<plugins>

<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>${git-commit-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion shared-assembler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>shared-assembler</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sword2-transport/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.dataconservancy.nihms</groupId>
<artifactId>nihms-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.6-2.2-SNAPSHOT</version>
</parent>

<artifactId>sword2-transport</artifactId>
Expand Down

0 comments on commit 390aec0

Please sign in to comment.