Deploy a war to Openshift 3 using Maven

Define the Maven plugin.

Embed this in a profile called openshift or whatever is passed to Maven via -P.

It can take a while to upload the war. Not hugely quick. Definitely needs a staged deployment approach.

<!-- Deploy the war to Openshift -->
<!-- http://www.mojohaus.org/exec-maven-plugin/examples/example-exec-using-executabledependency.html -->
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <executions>
        <execution>
            <id>openshift3-deploy-war</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <!-- path to oc tool -->
                <!-- https://blog.openshift.com/deploying-war-file-openshift-online-3/ -->
                <executable>${openshift.cli}</executable>
                <arguments>
                    <argument>start-build</argument>
                    <argument>${openshift.project.name}</argument>
                    <argument>--from-file=deployments/${project.build.finalName}.war</argument>
                    <argument>${openshift.config}</argument>
                </arguments>
            </configuration>
        </execution>
        <!-- Expose to the hinternet -->
        <execution>
            <id>openshift3-expose-route</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <!-- path to oc tool -->
                <!-- https://blog.openshift.com/deploying-war-file-openshift-online-3/ -->
                <executable>${openshift.cli}</executable>
                <arguments>
                    <argument>expose</argument>
                    <argument>svc</argument>
                    <argument>${openshift.project.name}</argument>
                    <argument>${openshift.config}</argument>
                </arguments>
            </configuration>
        </execution>
        <!-- Check out the route -->
        <execution>
            <id>openshift3-get-routes</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <!-- path to oc tool -->
                <!-- https://blog.openshift.com/deploying-war-file-openshift-online-3/ -->
                <executable>${openshift.cli}</executable>
                <arguments>
                    <argument>get</argument>
                    <argument>routes</argument>
                    <argument>${openshift.config}</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

Run the maven install.

$ mvn install -Popenshift -Dopenshift.cli=C:/Users/matto000/Documents/projects/openshift3/bin/oc.exe -Dopenshift.project.name=fireanote -Dopenshift.config=–config=C:/Users/matto000/.kube/config

[INFO] --- maven-war-plugin:2.3:war (default-war) @ fireanote-api ---
[INFO] Assembling webapp [fireanote-api] in [C:\Users\matto_000\Documents\projects\fireanote\fireanote-api\target\fireanote-api]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\matto_000\Documents\projects\fireanote\fireanote-api\src\main\webapp]
[INFO] Webapp assembled in [4938 msecs]
[INFO] Building war: C:\Users\matto_000\Documents\projects\fireanote\fireanote-api\deployments\fireanote-api.war
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.2.RELEASE:repackage (default) @ fireanote-api ---
[INFO] Replacing main artifact deployments\fireanote-api.war to C:\Users\matto_000\Documents\projects\fireanote\fireanote-api\target\fireanote-api.war
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ fireanote-api ---
[INFO] Installing C:\Users\matto_000\Documents\projects\fireanote\fireanote-api\target\fireanote-api.war to C:\Users\matto_000\.m2\repository\com\codejago\fireanote\fireanote-api\0.0.1-SNAPSHOT\fireanote-api-0.0.1-SNAPSHOT.war
[INFO] Installing C:\Users\matto_000\Documents\projects\fireanote\fireanote-api\pom.xml to C:\Users\matto_000\.m2\repository\com\codejago\fireanote\fireanote-api\0.0.1-SNAPSHOT\fireanote-api-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (openshift3-deploy-war) @ fireanote-api ---
Uploading file "deployments\\fireanote-api.war" as binary input for the build ...
build "fireanote-1" started
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (openshift3-expose-route) @ fireanote-api ---
route "fireanote" exposed
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:exec (openshift3-get-routes) @ fireanote-api ---
NAME        HOST/PORT                                                      PATH      SERVICES    PORT       TERMINATION   WILDCARD
fireanote   fireanote-fireanote.a3c1.starter-us-west-1.openshiftapps.com             fireanote   8080-tcp                 None
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20:29 min
[INFO] Finished at: 2017-09-06T23:22:33+01:00
[INFO] Final Memory: 48M/383M
[INFO] ------------------------------------------------------------------------