I'm currently developing a microservice based architecture for my application. I've got a maven multi-module project which has many services, so I can easily deploy them to the docker hub using the maven deploy command and also a maven docker plugin.
Still, the docker image tags are based in the project version number, while I would like to have them tagged with each repository's last changed revision number. From the time being, I'm trying just to add this field as a manifest entry using the buildnumber-maven-plugin:
Let's say that's my multi-module project:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
...
<modules>
<module>module-a</module>
<module>module-b</module>
</modules>
...
</project>
And the model for module-a would be:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<scm>
<connection>scm:svn:http://myrepo.com/svn/application/module-a</connection>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>true</doUpdate>
<useLastCommittedRevision>true</useLastCommittedRevision>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
....
</plugins>
</build>
<dependencies>
...
</dependencies>
</project>
The issue is that {buildNumber} evaluates to my working copy number, which is the one referring to the last commit made to the repository and not to the scm:svn:http://myrepo.com/svn/application/module-a
location. To explain it better, when I display the properties of module-a from tortoise I've got this:
What I want is to retrieve 3248 which refers to the last real change made to module-a, instead of 3257 (working copy), which is what I'm getting from the plugin. That way the docker plugin would know if it's a different image tag and push it only if changes were made to the module in the repo.