DevOps & Oracle Cloud

Iniziamo con un ottimo articolo di Fabrizio Marini, che affronta in maniera precisa due temi che saranno ricorrenti (e credo apprezzati) nel contesto di un moderno ciclo di sviluppo software: Continuous Integration e Cloud. La guida di Fabrizio fornisce in maniera chiara tutti i passi da seguire per:

  • Accedere al servizio Cloud
  • Creare un’istanza di servizio, un progetto e configurare tutti i meccanismi per un corretto deployment
  • Effettuare il deployment con successo ūüėČ

Potete trovare il post originale sul sito di Fabrizio. Enjoy!


For this guide you need only a laptop or PC with JDK8 and WLS12.1.3 already installed. (WLS is not mandatory but recommended)

If you are not interested on deploying the application on Java Cloud Service, you must follow only the task 3, 6
  1. Generate private and public keys (pub & ppk) for SSH communication
    • you will need a pub key for the creation of a new service in Oracle Java Cloud Service
    • you will need a ppk key for ssh communication from your laptop to Java Cloud Service
  2. Create a Service on Java Cloud Service
  3. Create a Project & a Git repository on Developer Cloud Service
  4. How to access in SSH to Java Cloud Service using Putty and ppk key
  5. How to setup a SSH communication between Developer Cloud Service and Java Cloud Service to enable the Deploy from DevCs to JCS
  6. How to create from scratch a Maven Project on Eclipse, synchronize it with a Git on Oracle Developer Cloud Service and finally how to use DevCS to build and deploy it on Java Cloud Service

If you follow this guide I suggest to look and follow this Gantt file that I have prepared for a customer that I follow.

This is a “pessimistic” Gantt, but it is an idea of¬†what to do during the waiting time of the creation of¬†Java Cloud Service, but as you can see, ¬†in around 4 hours (I was able to do this in 2 hours) you will be able to create an Hybrid DevOps architecture from scratch. (Task “Porting Application” is out of the scope of this guide).
Obviously for a new project you will spend few seconds, with Oracle Cloud Plug-in inside Eclipse, you will able to create a new project on premise and on cloud and synchronize it in a simple way.

DevOps & Oracle Cloud: How to create from scratch a Maven Project on Eclipse, synchronize it with a Git on Oracle Developer Cloud Service and finally how to use DevCS to build and deploy it on Java Cloud Service

I have used OEPE (Oracle Enterprise Pack for Eclipse) and you can download it from http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/index.html
Start your Eclipse(OEPE 12.2.1) and define a Workspace:

Click now on “Workbench” to continue:

This is the starting page of Eclipse:

In this example we will create a war maven project, to do this click on File->New->Other :

Select now Maven Project:

Click on next:

Scroll down and select maven-archetype-webapp:

Fill the Group Id and Artifact Id:

A new project will appear in the project explorer:

As you can see there are some errors on the project to solve them we must set a target runtime to add all the needed libraries:
Click on Project->Properties:

Select Targeted Runtimes

As runtime, select Oracle WebLogic 12.1.3 (the same version of the one selected on JCS):

Put where WLS12.1.3 is installed on your computer:

Select the Runtime, click apply and then Ok:

Now your Project is without errors:

Now we need to create a weblogic.xml inside WEB-INF directory, here we will set the Context Root of the Web Application, this is important because when you will Build and Deploy from DevCS to JCS if you do not set the Context Root, DevCS create it dynamically for each Build with a different name.

Look the next image as an example on how to set a Context Root:

Now we will add a Server to be able to compile and deploy and test the application on local computer:

Select Window->Show View->Other:

Select Server->Servers

Now on the right-down of Eclipse you can find Servers Tab, click the link to create anew server:

Select WebLogic 12.1.3:

Put where WLS 12.1.3 is installed on your computer:

Now in the servers tab appear your WebLogic:

We can build, deploy and run the application in a simple way:
Select index.jsp file, click on it and with right button of the mouse and select Run As->1 Run on Server:

Click finish:

WebLogic will start, and your jsp file will appear inside the browser of eclipse:

Now we will use Oracle cloud plug-in, to be able to put our project on DevCs (Developer Cloud Service):
Select Window->Show View->Other:

Select Oracle Cloud->Oracle Cloud:

Now click on the Connect link that is present on the Oracle Cloud Tab :

Here you must insert the Identity Domain of your DevCS service (Developer Cloud Service), the user and the password are the same that you use in the login page of DevCs: (Connection name is auto filling)

In the Oracle Cloud Tab will start the Fetching of the projects present on DevCs (this will takea while):

Now you can see the project that you have already created on DevCs:
[How to create a Project & Git repository on Developer Cloud Service]

Now with a simple Drag & Drop operation, put your project from Project Explorer, inside the project that appear on Oracle Clod tab , to push it on the Git of DevCs:

In my case I have dragged & dropped itpwork project from Project Explorer to the ITPWORK folder under developer50378 that appear in the Oracle Cloud  tab:

This pop-up will appear:
Check the Create Hudson build job and uncheck the Generate or update Maven …
Our poject is a maven project and already have a pom.xml

At the end,you will have your project on the Git on DevCs, and also inside a local git.

In you go on DevCS and you select your project (in this case ITPWORK), if you go on the Code Tab you will find now a copy of your project:

If you go in the Build Tab you will find a generic build job “Sample_Maven_Build” and the specific build job for your project created by Eclipse:

The first time this job will start automatically, and if all it is ok you will obtain a green icon in the status and a sun in the weather section:

If you click on the console icon under the action section of the previous image you can see the log and what was created:

Now that we are able to build the project, we can create the deploy job:
Go to the Deploy Tab and click new configuration:

Fill configuration and application name (I have used the same name of the war project) then select Java Service -> Select a Remote Target (where you want to deploy)  :

Put the public ip address of your JCS Service, use the 9001 port (by default on JCS on the Admin Server there is a http channel on port 9001) user and password are the same that you are using when you login in the WebLogic Console:

The test will Fail is you have not done
[ How to setup a SSH communication between Developer Cloud Service and Java Cloud Service to enable the Deploy from DevCs to JCS ] :

Select “Automatic”, the deploy will start automatically after a build job.
Select the build job previously created by Eclipse, select your Artifact:

The first time the deploy will start automatically:

If you select the Build tab, you can start your build job selecting the Build Now icon under Actions:

Then you can see a progress bar for your build job:

At the end of the build job, the deploy job will start automatically:

If you open the Admin console, under deployments you can find you new Application Deployed and Active:

We can call and test now the application using the load balancer:

You can find all the Public IP on your JCS service:
[How to create a Service in Oracle Java Cloud Service]

Now as sample we will modify the jsp page on Eclipse and we will rebuild and redeploy the application from DevCs to JCS:

Go on Eclpise and add some text to the jsp:

We will update the Git on DevCS with the new version of the jsp:
Select the jsp then click on it with the right button of the mouse, select Team->Commit

Insert a Comment in the Commit Message, this will appear on DevCs, select the jsp you have changed, click on “commit and push“:

Click ok:

Open your DevCs and select the Code Tab, you will find what you have just added with your comment:

if you click on it you can see the differences in your code from the previous version:

Restart your build job, at the end the deploy will be automatic:

Wait and be sure that the deploy has finished, then if you call your application you can see that is a new version:

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s