update docker image tags

Issue-ID: DMAAP-1042
Change-Id: I20bfb6aa960bcdedfe85e01d3ee66a77b8e070c8
Signed-off-by: sunil unnava <sunil.unnava@att.com>
diff --git a/pom.xml b/pom.xml
index 0dbf611..de92696 100644
--- a/pom.xml
+++ b/pom.xml
@@ -110,8 +110,8 @@
 					<dockerDirectory>${dockerLocation}</dockerDirectory>
 					<serverId>docker-hub</serverId>
 					<imageTags>
-						<imageTag>${dmaapImg}</imageTag>
-						<imageTag>latest</imageTag>
+						<imageTag>${dockertag1}</imageTag>
+						<imageTag>${dockertag2}</imageTag>
 					</imageTags>
 					<forceTags>true</forceTags>
 					<resources>
@@ -147,7 +147,7 @@
 						</goals>
 						<configuration>
 							<image>onap/dmaap/dmaap-mr</image>
-							<newName>${docker.push.registry}/onap/dmaap/dmaap-mr:${project.version}</newName>
+							<newName>${docker.push.registry}/onap/dmaap/dmaap-mr:${dockertag2}</newName>
 							<skipDockerTag>${skip.docker.push}</skipDockerTag>
 						</configuration>
 					</execution>
@@ -160,7 +160,7 @@
 						</goals>
 						<configuration>
 							<image>onap/dmaap/dmaap-mr</image>
-							<newName>${docker.push.registry}/onap/dmaap/dmaap-mr:latest</newName>
+							<newName>${docker.push.registry}/onap/dmaap/dmaap-mr:${dockertag1}</newName>
 							<skipDockerTag>${skip.docker.push}</skipDockerTag>
 						</configuration>
 					</execution>
@@ -172,7 +172,7 @@
 							<goal>push</goal>
 						</goals>
 						<configuration>
-							<imageName>${docker.push.registry}/onap/dmaap/dmaap-mr:${project.version}</imageName>
+							<imageName>${docker.push.registry}/onap/dmaap/dmaap-mr:${dockertag2}</imageName>
 							<skipDockerPush>${skip.docker.push}</skipDockerPush>
 						</configuration>
 					</execution>
@@ -184,7 +184,7 @@
 							<goal>push</goal>
 						</goals>
 						<configuration>
-							<imageName>${docker.push.registry}/onap/dmaap/dmaap-mr:latest</imageName>
+							<imageName>${docker.push.registry}/onap/dmaap/dmaap-mr:${dockertag1}</imageName>
 							<skipDockerPush>${skip.docker.push}</skipDockerPush>
 						</configuration>
 					</execution>
@@ -262,7 +262,8 @@
 		<testRouteOffer>workstation</testRouteOffer>
 		<testEnv>DEV</testEnv>
 		<!-- <dmaapImg>${project.version}</dmaapImg> -->
-		<dmaapImg>1.1.10</dmaapImg>
+		<timestamp>${maven.build.timestamp}</timestamp>
+        <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
 		<camel.version>2.21.1</camel.version>
 		<sitePath>/content/sites/site/org/onap/dmaap/messagerouter/messageservice/${project.artifactId}/${project.version}</sitePath>
 		<skip.docker.build>true</skip.docker.build>
@@ -726,11 +727,48 @@
 		<profile>
 			<id>docker</id>
 			<properties>
-
 				<skip.docker.build>false</skip.docker.build>
 				<skip.docker.tag>false</skip.docker.tag>
 				<skip.docker.push>false</skip.docker.push>
 			</properties>
+			<build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.groovy.maven</groupId>
+                        <artifactId>gmaven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>validate</phase>
+                                <goals>
+                                    <goal>execute</goal>
+                                </goals>
+                                <configuration>
+                                    <properties>
+                                        <ver>${project.version}</ver>
+                                        <timestamp>${maven.build.timestamp}</timestamp>
+                                    </properties>
+                                    <source>
+                                        println project.properties['ver'];
+                                        def versionArray;
+                                        if ( project.properties['ver'] != null ) {
+                                        versionArray = project.properties['ver'].split('\\.');
+                                        }
+                                        if ( project.properties['ver'].endsWith("-SNAPSHOT") ) {
+                                        project.properties['dockertag1']=project.properties['ver'] + "-latest";
+                                        project.properties['dockertag2']=project.properties['ver'] + "-" + project.properties['timestamp'];
+                                        } else {
+                                        project.properties['dockertag1']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";
+                                        project.properties['dockertag2']=project.properties['ver'] + "-STAGING-" + project.properties['timestamp'];
+                                        }
+                                        println 'docker tag 1: ' + project.properties['dockertag1'];
+                                        println 'docker tag 2: ' + project.properties['dockertag2'];
+                                    </source>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    </plugins>
+                    </build>
 		</profile>
 
 		<profile>