Add Docker tags 01/9701/2
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Thu, 31 Aug 2017 15:23:57 +0000 (17:23 +0200)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Thu, 31 Aug 2017 15:45:17 +0000 (17:45 +0200)
Add docker tags SNAPSHOT and STAGING to the current ones for automation

Change-Id: I330271ec169cba33d0b92579e39afeed55795bd0
Issue-Id: CLAMP-43
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
pom.xml
src/main/script/TagVersion.groovy [new file with mode: 0644]

diff --git a/pom.xml b/pom.xml
index c1ec0e2..8bcd5ef 100644 (file)
--- a/pom.xml
+++ b/pom.xml
        <version>1.0.1-SNAPSHOT</version>
        <name>ONAP CLAMP</name>
 
-       <parent>
-               <groupId>org.onap.oparent</groupId>
-               <artifactId>oparent</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
-       </parent>
+<!--   <parent> -->
+<!--           <groupId>org.onap.oparent</groupId> -->
+<!--           <artifactId>oparent</artifactId> -->
+<!--           <version>1.0.0-SNAPSHOT</version> -->
+<!--   </parent> -->
 
        <description>
            This project build the ONAP CLAMP JAR that contains AJSC + CLAMP code.
@@ -57,6 +57,9 @@
     </description>
 
        <properties>
+               <maven.build.timestamp.format>yyyy.MM.dd'T'hh.mm.ss'Z'</maven.build.timestamp.format>
+               <clamp.project.version>${project.version}</clamp.project.version>
+               <clamp.build.timestamp>${maven.build.timestamp}</clamp.build.timestamp>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <dependency>
                        <groupId>org.onap.policy.engine</groupId>
                        <artifactId>PolicyEngineAPI</artifactId>
-                       <version>1.1.0-SNAPSHOT</version>
+                       <version>1.1.0</version>
                        <exclusions>
                                <exclusion>
                                        <artifactId>log4j</artifactId>
                <dependency>
                        <groupId>org.onap.policy.common</groupId>
                        <artifactId>ONAP-Logging</artifactId>
-                       <version>1.1.0-SNAPSHOT</version>
+                       <version>1.1.0</version>
                        <exclusions>
                                <exclusion>
                                        <artifactId>log4j</artifactId>
                </resources>
 
                <plugins>
+                       <plugin>
+                               <groupId>org.codehaus.groovy.maven</groupId>
+                               <artifactId>gmaven-plugin</artifactId>
+                               <version>1.0</version>
+                               <executions>
+                                       <execution>
+                                               <phase>validate</phase>
+                                               <goals>
+                                                       <goal>execute</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <source>${project.basedir}/src/main/script/TagVersion.groovy</source>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                        <dockerDirectory>src/main/docker</dockerDirectory>
                                        <serverId>docker-hub</serverId>
                                        <imageTags>
-                                               <imageTag>${project.version}</imageTag>
                                                <imageTag>latest</imageTag>
+                                               <imageTag>${project.docker.latesttagtimestamp.version}</imageTag>
+                                               <imageTag>${project.docker.latesttag.version}</imageTag>
                                        </imageTags>
                                        <forceTags>true</forceTags>
                                        <resources>
                                                        <goal>push</goal>
                                                </goals>
                                                <configuration>
-                                                   <imageName>${docker.push.registry}/onap/clamp</imageName>
+                                                       <imageName>${docker.push.registry}/onap/clamp</imageName>
                                                        <skipDockerPush>${skip.docker.push}</skipDockerPush>
                                                </configuration>
                                        </execution>
                                                </configuration>
                                        </execution>
                                        <execution>
-                        <goals>
-                            <goal>merge</goal>
-                        </goals>
-                        <phase>post-integration-test</phase>
-                        <configuration>
-                            <fileSets>
-                                <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
-                                    <directory>${project.build.directory}/coverage-reports</directory>
-                                    <includes>
-                                        <include>*.exec</include>
-                                    </includes>
-                                </fileSet>
-                            </fileSets>
-                            <destFile>${project.build.directory}/jacoco-dev.exec</destFile>
-                        </configuration>
-                    </execution>
+                                               <goals>
+                                                       <goal>merge</goal>
+                                               </goals>
+                                               <phase>post-integration-test</phase>
+                                               <configuration>
+                                                       <fileSets>
+                                                               <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
+                                                                       <directory>${project.build.directory}/coverage-reports</directory>
+                                                                       <includes>
+                                                                               <include>*.exec</include>
+                                                                       </includes>
+                                                               </fileSet>
+                                                       </fileSets>
+                                                       <destFile>${project.build.directory}/jacoco-dev.exec</destFile>
+                                               </configuration>
+                                       </execution>
                                </executions>
                        </plugin>
 
                        <properties>
                                <skip.staging.artifacts>true</skip.staging.artifacts>
                                <skip.docker.build>false</skip.docker.build>
-                               <skip.docker.tag>false</skip.docker.tag>
-                               <skip.docker.push>false</skip.docker.push>
+                               <skip.docker.tag>true</skip.docker.tag>
+                               <skip.docker.push>true</skip.docker.push>
                        </properties>
                </profile>
        </profiles>
diff --git a/src/main/script/TagVersion.groovy b/src/main/script/TagVersion.groovy
new file mode 100644 (file)
index 0000000..c365da8
--- /dev/null
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.maven.scripts
+
+println project.properties['clamp.project.version']; 
+def versionArray; 
+if ( project.properties['clamp.project.version'] != null ) { 
+    versionArray = project.properties['clamp.project.version'].split('\\.'); 
+} 
+
+if ( project.properties['clamp.project.version'].endsWith("-SNAPSHOT") ) { 
+    project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-SNAPSHOT-latest";
+    project.properties['project.docker.latesttagtimestamp.version']=versionArray[0] + '.' + versionArray[1] + "-SNAPSHOT-"+project.properties['clamp.build.timestamp']; 
+} else { 
+    project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";
+    project.properties['project.docker.latesttagtimestamp.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-"+project.properties['clamp.build.timestamp'];
+} 
+
+println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'];
\ No newline at end of file