
Part II: Continuous Deployment to App Container Cloud using Developer Cloud service
Posted by Abhishek Gupta-Oracle in Developer Solutions on Sep 12, 2016 8:12:32 AMPart I of this blog series covered the specifics of building our lightweight Java EE application - Ticker Tracker. This part will focus on the following aspects
- Leveraging NetBeans IDE while working with Oracle Developer Cloud service. This includes
- Setting up the Team Server plugin
- Leveraging it to interact with Developer Cloud service instance from within your IDE
- Priming Developer Cloud service for Continuous Deployment
Oracle Developer Cloud Service is a cloud-based software development Platform as a Service (PaaS) and a hosted environment for your application development infrastructure. It provides an open source standards-based solution to develop, collaborate, build, and deploy applications within Oracle Cloud. It provides a number of services such as
- Source code management
- Build Automation
- Continuous Integration
- Issue tracking
- Code review
- Deployment automation
- Agile process management
- Wiki
- Activity Stream
Let’s dive into the details now…
Using the Team Server plugin with NetBeans IDE
Leveraging NetBeans Team Server plugin along with the automated build & deploy features in Developer Cloud (explained in sections below) lets you stay within your IDE and enjoy a seamless development experience. Using NetBeans IDE to Create an Oracle Developer Cloud Service Project is a great tutorial to understand the details
Download & setup the Team Server plugin in NetBeans IDE
This is a fairly straightforward process and you can refer to the Installing the Team Server Plugin for NetBeans IDE section from Using NetBeans IDE to Create an Oracle Developer Cloud Service Project tutorial to get this up and running
Importing the project into NetBeans
This section provides a quick outline of the steps involved
You should see a similar project structure in your IDE
Configure the Oracle Developer Cloud instance within NetBeans
The Adding the Team Server for Your Oracle Cloud Developer Service Instance to Your NetBeans IDE Instance section provides clear instructions for these steps
Creating the project in Oracle Developer Cloud
The steps involved are outlined below
Use the Team pane, select the Developer Cloud instance and choose New Project
Enter the details such as project name, description etc.
In this step, we will link our Ticker Tracker application repository (source) to the project which is being created
Log into your Oracle Developer Cloud Service instance to explore the new project
Push your project to the Oracle Developer Cloud Git repository
What follows is a series of Git related steps which are applicable when working with any such Git repository. In this case, we are working against the repository which was automatically setup for us when we initially created the project in Developer Cloud Service
Since we already linked our project to the Git repository in the project, all that’s required is a Git > Remote > Push to Upstream, without having to explicitly provide Git repo information like location, credentials etc.
Check your Oracle Developer Cloud service instance to ensure that the source code is now present in the master branch
Configure Oracle Developer Cloud
Configure build job
We will need to configure the build job in Developer Cloud. It will take care of the following
- Invoking our Maven build based off the source in out Git repo
- Prepare our Zip artifact which is a deployable artifact compliant with the Application Container Cloud
All in all, this is a traditional Build configuration which you can read about in the documentation here. The components of the build configuration have been highlighted below
Note: The business logic in the Ticker Tracker application itself does not have any dependency on JDK 8 and can be compiled with JDK 7. In case you’re wondering why we need JDK 8 - it is because Wildfly Swarm build plugin is dependent on the same, hence the build process will require it as well. The good part is that Oracle Developer Cloud Service makes this configurable and provides you the flexibility
Select the project Git repository as the Source for the build process
Configure your build process to trigger on commits to your Git repository (read more in the Configuring Build Triggers section). This is important from a Continuous Integration perspective
A note on ‘cloud-ready’ package
Before you explore the next set of steps, it would be good to recap the fact that, in the context of Application Container Cloud, a valid deployment artifact is a ZIP file which consists of not only the (uber) JAR, plus other metadata files such as manifest.json, deployment.json etc
Developer Cloud build configuration invokes the maven build which creates the Uber JAR (thanks to the Wildfly Maven plugin), but the Application Container Cloud compliant ZIP is created by including an additional Build Step (highlighted below)
zip -j target/ticker-tracker.zip target/ticker-tracker-swarm.jar manifest.json
The above shell command is executed after the Maven build and it packages the Uber JAR along with the mandatory deployment descriptor (manifest.json) as a ZIP file
Configure & initiate (manual) deployment
In addition to automating your build process (as explained previously), Developer Cloud service also enables you to deploy your Java applications to Application Container Cloud (details are available in the product documentation)
Initiate the process by navigating to Deploy > New Configuration
Enter the details corresponding to your Application Container cloud instance
Note: You can deploy to any instance of Application Container Cloud (irrespective of whether or not it is in the same identity domain as the Developer Cloud service
Complete the deployment configuration and start the process
At the same time, log into Application Container Cloud service and look at the Applications section and verify that the deployment is in fact in flight
The below screenshot depicts a successfully completed deployment process
Post deployment completion, you can also explore further details about the application (in Application Container Cloud) by clicking on the application name
You might also want to refer this tutorial - Creating a Project from a Template and Deploying It to Oracle Application Container Cloud Service
But we need Continuous Deployment !
So far, you were able to
- configure the NetBeans project along with the Team Server plugin
- push the project to Oracle DevCS git repository
- configure the build and initiate it manually
Now, we’ll look the final piece of the puzzle – Continuous Deployment from Developer Cloud to Application Container Cloud
Back to the deployment configuration
Your post build process should be configured to trigger automatic deployment to Application Container Cloud (details available here). You can tweak the existing deployment configuration to weave the CI/CD magic!
Ensure that you check the Automatic radio button. In this scenario, we have opted to deploy stable builds only
Make a code change, commit, push & monitor build from your IDE
After you initiate Push to Upstream (as demonstrated previously), and refresh the application view on your Team view, you will notice (after some time) that the build process has been automatically kicked off (thanks to the configuration we just made)
You can track the build progress in real time from within your IDE
The same would reflect in your Developer Cloud console as well (as expected)
Quick recap..
Since this post had a lot to do with configuration (than code!) it’s easy to lose track. Here is a quick summary of what we did
- Bootstrapped our project, application (and its source) within Developer Cloud service using the Team Server plugin for NetBeans – this served as the foundation for handling other life cycle activities related to our application
- Configured Developer Cloud Service
- Build process
- Deployment process
- Tweaked both to enable CI/CD
Conclusion
This marks the end of this 2-part blog series. In case you stumbled onto this post directly, here is the link for the first part. There is obviously more to Oracle Developer Cloud (as well as Application Container Cloud) than what has been covered via this blog post and the official product documentation is probably the best place to start digging in further.
**The views expressed in this post are my own and do not necessarily reflect the views of Oracle.
Comments