summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChrisC <christophe.closset@intl.att.com>2020-06-12 10:31:14 +0200
committerChrisC <christophe.closset@intl.att.com>2020-06-12 14:47:11 +0200
commit4d19876e687e3c6bec24e967c2812a46669de94e (patch)
tree67bc3aab3f9d0ebcb3a368d3beb9d8280d49a1a8
parente373c54d113f93f3d3057506db65b4fd4b02c16e (diff)
Add Labels to Docker images
Add vcs_ref and vcs_branch as labels in the maven docker build Added a profile to make this work both in local and with Gerrit Issue-ID: SDC-3113 Signed-off-by: ChrisC <christophe.closset@intl.att.com> Change-Id: I341341fe7846b974e5275dcf150d5111c686f38c
-rw-r--r--pom.xml86
1 files changed, 86 insertions, 0 deletions
diff --git a/pom.xml b/pom.xml
index 5cab49a..6613c29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,9 @@
<tag>${docker.tag}</tag>
<tag>${docker.latest.tag}</tag>
</tags>
+ <buildOptions>
+ <labels>{"vcs_branch":"${scmBranch}","vcs_ref":"${scmRevision}"}</labels>
+ </buildOptions>
<dockerFileDir>${project.basedir}/base_sdc-jetty</dockerFileDir>
</build>
</image>
@@ -58,6 +61,9 @@
<tag>${docker.tag}</tag>
<tag>${docker.latest.tag}</tag>
</tags>
+ <buildOptions>
+ <labels>{"vcs_branch":"${scmBranch}","vcs_ref":"${scmRevision}"}</labels>
+ </buildOptions>
<dockerFileDir>${project.basedir}/base_sdc-cassandra</dockerFileDir>
</build>
</image>
@@ -71,6 +77,9 @@
<tag>${docker.tag}</tag>
<tag>${docker.latest.tag}</tag>
</tags>
+ <buildOptions>
+ <labels>{"vcs_branch":"${scmBranch}","vcs_ref":"${scmRevision}"}</labels>
+ </buildOptions>
<dockerFileDir>${project.basedir}/base_sdc-cqlsh</dockerFileDir>
</build>
</image>
@@ -84,6 +93,9 @@
<tag>${docker.tag}</tag>
<tag>${docker.latest.tag}</tag>
</tags>
+ <buildOptions>
+ <labels>{"vcs_branch":"${scmBranch}","vcs_ref":"${scmRevision}"}</labels>
+ </buildOptions>
<dockerFileDir>${project.basedir}/base_sdc-python</dockerFileDir>
</build>
</image>
@@ -97,6 +109,9 @@
<tag>${docker.tag}</tag>
<tag>${docker.latest.tag}</tag>
</tags>
+ <buildOptions>
+ <labels>{"vcs_branch":"${scmBranch}","vcs_ref":"${scmRevision}"}</labels>
+ </buildOptions>
<dockerFileDir>${project.basedir}/base_sdc-sanity</dockerFileDir>
</build>
</image>
@@ -110,6 +125,9 @@
<tag>${docker.tag}</tag>
<tag>${docker.latest.tag}</tag>
</tags>
+ <buildOptions>
+ <labels>{"vcs_branch":"${scmBranch}","vcs_ref":"${scmRevision}"}</labels>
+ </buildOptions>
<dockerFileDir>${project.basedir}/base_sdc-vnc</dockerFileDir>
</build>
</image>
@@ -152,8 +170,76 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <id>gen-scm-info</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <doCheck>false</doCheck>
+ <shortRevisionLength>8</shortRevisionLength>
+ <buildNumberPropertyName>scmRevision</buildNumberPropertyName>
+ </configuration>
+ </plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>gerrit-only</id>
+ <activation>
+ <property>
+ <name>GERRIT_BRANCH</name>
+ </property>
+ </activation>
+ <properties>
+ <scmBranch>${GERRIT_BRANCH}</scmBranch>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <id>gen-scm-info</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>regex-property</id>
+ <goals>
+ <goal>regex-property</goal>
+ </goals>
+ <configuration>
+ <name>scmRevision</name>
+ <value>${GERRIT_PATCHSET_REVISION}</value>
+ <regex>.{0,32}$</regex>
+ <replacement></replacement>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<repositories>
<repository>
<id>central</id>