Build changes to generate docker staging images for optf-has 00/103800/1
authorvrvarma <vikas.varma@att.com>
Tue, 17 Mar 2020 14:58:26 +0000 (10:58 -0400)
committervrvarma <vikas.varma@att.com>
Tue, 17 Mar 2020 14:58:54 +0000 (10:58 -0400)
Change-Id: I4e9fa87c7b7aed47d73c9a2f39f2f893a57a731a
Signed-off-by: vrvarma <vikas.varma@att.com>
Issue-ID: OPTFRA-718

conductor/pom.xml
pom.xml
script/TagVersion.groovy [new file with mode: 0644]

index e914da3..5188397 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
 <!--
     Copyright (c) 2018 Intel Corporation. All rights reserved.
+    Copyright (c) 2020 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
                     </execution>
                 </executions>
             </plugin>
+            <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}/../script/TagVersion.groovy</source>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       <plugin>
+                               <groupId>io.fabric8</groupId>
+                               <artifactId>docker-maven-plugin</artifactId>
+                               <version>0.26.0</version>
+                               <configuration>
+                                       <verbose>true</verbose>
+                                       <apiVersion>1.23</apiVersion>
+                                       <images>
+                                               <image>
+                                                       <name>${image.namespace}</name>
+                                                       <alias>optf-has</alias>
+                                                       <build>
+                                                               <cleanup>true</cleanup>
+                                                               <tags>
+                                                                       <tag>latest</tag>
+                                                                       <tag>${project.docker.latesttagtimestamp.version}</tag>
+                                                                       <tag>${project.docker.latesttag.version}</tag>
+                                                               </tags>
+
+                                                               <dockerFile>${project.basedir}/docker/Dockerfile</dockerFile>
+                                                               <args>
+                                                                       <MVN_ARTIFACT_VERSION>${project.version}</MVN_ARTIFACT_VERSION>
+                                                                       <REPO>${project.repo}</REPO>
+                                                               </args>
+                                                       </build>
+                                               </image>
+                                       </images>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <id>generate-images</id>
+                                               <phase>install</phase>
+                                               <goals>
+                                                       <goal>build</goal>
+                                               </goals>
+                                       </execution>
+                                       <execution>
+                                               <id>push-images</id>
+                                               <phase>deploy</phase>
+                                               <goals>
+                                                       <goal>build</goal>
+                                                       <goal>push</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <image>${image.namespace}:%l</image>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
         </plugins>
     </build>
 </project>
diff --git a/pom.xml b/pom.xml
index bf7bbf7..14f5ec9 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <sonar.exclusions>**/tests/**,setup.py,**/lib/**</sonar.exclusions>
         <sonar.test.inclusions>**/tests/**.py</sonar.test.inclusions>
         <sonar.test.exclusions>**/**.py,setup.py,**/lib/**</sonar.test.exclusions>
+        <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
+               <has.build.timestamp>${maven.build.timestamp}</has.build.timestamp>
+               <has.project.version>${project.version}</has.project.version>
+               <has.docker.repository>nexus3.onap.org:10003</has.docker.repository>
+               <image.namespace>${has.docker.repository}/onap/optf-has</image.namespace>
     </properties>
 
     <build>
diff --git a/script/TagVersion.groovy b/script/TagVersion.groovy
new file mode 100644 (file)
index 0000000..468b2d4
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP HAS
+ * ================================================================================
+ * Copyright (C) 2020 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============================================
+ * ===================================================================
+ * 
+ */
+
+package org.onap.has.maven.scripts
+
+println project.properties['has.project.version']
+
+def versionTag
+if ( project.properties['has.project.version'] != null ) {
+    versionArray = project.properties['has.project.version'].split('\\.|-');
+    versionTag = versionArray[0] + '.' + versionArray[1] + '.' + versionArray[2]
+    timestamp = project.properties['has.build.timestamp']
+}
+
+if ( project.properties['has.project.version'].endsWith("-SNAPSHOT") ) {
+    project.properties['project.docker.latesttag.version']=versionTag + "-SNAPSHOT-latest";
+    project.properties['project.docker.latesttagtimestamp.version']=versionTag + "-SNAPSHOT-"+timestamp;
+    project.properties['project.repo'] = 'snapshots'
+} else { 
+    project.properties['project.docker.latesttag.version']=versionTag + "-STAGING-latest";
+    project.properties['project.docker.latesttagtimestamp.version']=versionTag + "-STAGING-"+timestamp;
+    project.properties['project.repo'] = 'releases'
+} 
+
+println 'New Tag for docker: ' + project.properties['project.docker.latesttag.version'];
\ No newline at end of file