If you have just create your account  and wondering what is the fastest way to see something running on the cloud, then you are on the right place!

So, we look for faster possible (hopefully automated) way to execute following steps:

  1. Get tools and SDK
  2. Create an application
  3. Compile and package it
  4. Deploy it
  5. Start it
  6. Access it

Ok, now we have a plan let see how we can automate as many as possible of those tasks.

Let assume that you already have Java installed.

As we want to automate we will need some tools for task automation. I prefer maven and hope you too. The tool is really powerful and installation is very simple.

In short – download it, unpack it, export in environment M2_HOME variable to point to folder where you unpack maven and add M2_HOME/bin to your path variable:

export M2_HOME=<path to folder with unpacked maven>/maven

export PATH=${M2_HOME}/bin:${PATH}

We can use the maven templating toolkit and specifically the archetype for web applications “maven-archetype-webapp” to fully generate the simple “hello world” web application.

For the automation of other tasks we will look at what our cloud experts say in SCN.

In article “Working with the “Neo” Maven Plugin” Vedran Lerenc explains how we can use maven for SDK installation, application packaging and deployment on the cloud.

And in this example Stephan Merker gives a more complex scenario, by covering other application life cycle operations such as start/stop and undeploy.

Now we have the knowledge and can proceed with the automation of all steps from our plan.

The expectations are that the whole scenario from beginning to end will take us less that 5 minutes (including a little more than 1 minute waiting for application to start on the cloud before accessing it 😉 )

Step1 – Application generation

Create an empty folder for this experiment and execute following command:

mvn archetype:generate -DgroupId=com.acme.hello -DartifactId=com.acme.hello.webapp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

GenerateProject.png

Step 2 – Build, Package, Stop (in case it was already started), Deploy, Start

All those steps will become a part of the pom.xml file that was generated for us in Step 1.

Open the pom.xml file and add inside following content:

<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/maven-v4_0_0.xsd“>

     <modelVersion>4.0.0</modelVersion>

     <groupId>com.acme.hello</groupId>

     <artifactId>com.acme.hello.webapp</artifactId>

     <packaging>war</packaging>

     <version>1.0-SNAPSHOT</version>

     <name>com.acme.hello.webapp Maven Webapp</name>

     <url>http://maven.apache.org</url>

     <dependencies>

          <dependency>

               <groupId>junit</groupId>

               <artifactId>junit</artifactId>

               <version>3.8.1</version>

               <scope>test</scope>

          </dependency>

          <dependency>

               <groupId>com.sap.cloud</groupId>

               <artifactId>neo-java-web-api</artifactId>

               <version>${sdk.version}</version>

               <scope>provided</scope>

          </dependency>

     </dependencies>

     <build>

          <finalName>com.acme.hello.webapp</finalName>

          <plugins>

               <plugin>

                    <groupId>com.sap.cloud</groupId>

                    <artifactId>neo-java-web-maven-plugin</artifactId>

                    <version>${sdk.version}</version>

                    <executions>

                         <execution>

                              <phase>install</phase>

                              <goals>

                                   <goal>install-sdk</goal>

                                   <goal>stop</goal>

                                   <goal>deploy</goal>

                                   <goal>start</goal>

                              </goals>

                              <configuration>

                                   <sdkInstallPath>${project.build.directory}/sdk</sdkInstallPath>

                                   <host>${sap.cloud.host}</host>

                                   <user>${sap.cloud.username}</user>

                                   <password>${sap.cloud.password}</password>

                                   <account>${sap.cloud.account}</account>

                                   <application>${sap.cloud.application}</application>

                                   <source>${project.build.directory}/${project.artifactId}.war</source>

                                   <synchronous>true</synchronous>

                               

                                   <!– proxy related information – if not behind proxy remove next 4 lines –>

                                   <consoleHttpProxyHost>${proxy.host}</consoleHttpProxyHost>

                                   <consoleHttpProxyPort>${proxy.port}</consoleHttpProxyPort>

                                   <consoleHttpsProxyHost>${proxy.host}</consoleHttpsProxyHost>

                                   <consoleHttpsProxyPort>${proxy.port}</consoleHttpsProxyPort>

                              </configuration>

                         </execution>

                    </executions>

               </plugin>

          </plugins>

     </build>

     <properties>

          <sdk.version>2.11.3</sdk.version>  

          <sap.cloud.host>hanatrial.ondemand.com</sap.cloud.host>

          <sap.cloud.application>hellomaven</sap.cloud.application>

      

          <!– you need to fill your account information here –>

          <sap.cloud.account>account_name_here</sap.cloud.account>

          <sap.cloud.username>user_name_here</sap.cloud.username>

          <sap.cloud.password>password_here</sap.cloud.password>

      

          <!– proxy related information here – if not behind proxy remove next 2 lines –>

          <proxy.host>proxy_host_here</proxy.host>

          <proxy.port>proxy_port_here</proxy.port>

     </properties>

</project>


Fill the sections that refer account information and proxy settings inside pom.xml. Keep in mind that this is not secure at all, but it is the faster approach 😉 .

ℹ If you want to make this secure and use it as part of continuous integration process (jenkins) use environment variables as they are used in this example.

When you finish editing the file, save it and execute the following:

cd com.acme.hello.webapp/

mvn clean install

StartMVNBuild.png

When you get this result:

EndMVNBuild.png

This means the application is now started on the cloud.

Let go and see it.

Step 3 – Access it

Open the cockpit in your browser (https://account.hanatrial.ondemand.com/) and look for application “hellomaven” there:

AppInCockpit.png

Then open the link inside Application URLs section and you will get this:

ExecutedApp.png

And we are done!

Let’s check the times

1. Generating the application took 16 sec

2. Editing the pom.xml file took less than 1 minute

3. Building, packaging, deploying and installing took 1 minute and 17 seconds

4. Accessing the application took less than 1 minute

So from nothing to an application on the cloud in less than 4 minutes (less than 3 minutes and 33 seconds actually)


I dare you to beat this result 😉

Enjoy,

Dobri

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply