This blog covers CI/CD for a Java application deployed on Oracle Application Container Cloud which uses Oracle Database Cloud via its declarative Service Binding feature

 

  • We will focus on setting up and configuring Oracle Developer Cloud Service to achieve end-to-end DevOps and specifically look at
    • Continuous Deployment to Application Container Cloud
    • Using Oracle Maven repository from Developer Cloud Service
  • The scenario depicted here will be used as a reference

 

 

Quick background

Here is an overview

  • APIs used: The application leverages JPA (DB persistence) and JAX-RS (for REST) APIs
  • Oracle Database Cloud Service: The client (web browser/curl etc) invokes a HTTP(s) URL (GET request) which internally calls the JAX-RS resource, which in turn invokes the JPA (persistence) layer to communicate with Oracle Database Cloud instance
  • Application Container Cloud Service bindings in action: Connectivity to the Oracle Database Cloud instance is achieved with the help of a service binding which exposes database connectivity details as environment variables which are then within the code

 

For more details you can refer to the following sections from one of my previous blogs - About the sample and Service Bindings concept

 

Using Oracle Maven within Oracle Developer Cloud

The instructions in the previous blog included a manual step to seed the Oracle JDBC driver (ojdbc7.jar) into the local Maven local repository. In this blog however, we will see leverage Oracle Maven repository (one time registration required for access) for the same. Developers generally need to go through a bunch of steps to before starting to use the Oracle Maven repo (e.g. configuring Maven settings.xml etc.), but Oracle Developer Cloud service handles all this internally! All you need to do is provide your repository credentials along with any customizations if needed. More on this in upcoming section

 

Here is snippet from the pom.xml which highlights the usage of the Oracle Maven repository

 

 

    <repositories>
        <repository>
            <id>maven.oracle.com</id>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <url>https://maven.oracle.com</url>
            <layout>default</layout>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>maven.oracle.com</id>
            <url>https://maven.oracle.com</url>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>

 

Setting up Developer Cloud Service

 

Project & code repository creation

Please refer to the Project & code repository creation section in the Tracking JUnit test results in Developer Cloud service blog or check the product documentation for more details

 

Configure source code in Git repository

Push the project from your local system to your Developer Cloud Git repo you just created. We will do this via command line and all you need is Git client installed on your local machine. You can use Git or any other tool of your choice

 

cd <project_folder> //where you unzipped the source code  
git init  
git remote add origin <developer_cloud_git_repo>  
//e.g. https://john.doe@developer.us.oraclecloud.com/developer007-foodomain/s/developer007-foodomain-project_2009/scm/sample.git//john.doe@developer.us.oraclecloud.com/developer007-foodomain/s/developer007-foodomain-project_2009/scm/sample.git   
git add .  
git commit -m "first commit"  
git push -u origin master  //Please enter the password for your Oracle Developer Cloud account when prompted

 

 

Configure build

Create a New Job

 

 

Basic Configuration

Select JDK

 

 

 

Source Control

Choose Git repository

 

 

 

Build Trigger (Continuous Integration)

Set build trigger - this build job will be triggered in response to updated within the Git repository (e.g. via git push)

 

 

 

Configure Oracle Maven repository

As mentioned above, we will configure Oracle Developer Cloud to use the Oracle Maven repository – the process is quite simple. For more details, refer product documentation

 

 

 

Build steps

A Maven Build step – to produce the ZIP file to be deployed to Application Container Cloud

 

 

Post-Build actions

 

Activate a post build action to archive deployable zip file

 

 

Execute Build

Before configuring deployment, we need to trigger the build in order to produce the artifacts which can be referenced by the deployment configuration

 

 

After the build is complete, you can check the archived artifacts

 

 

Continuous Deployment (CD) to Application Container Cloud

Create a New Confguration for deployment

 

 

 

  • Enter the required details and configure the Deployment Target
  • Configure the Application Container Cloud instance
  • Configure Automatic deployment option on the final confirmation page
  • Provide content for manifest.json and deployment.json

 

You’ll end up with the below configuration (the view has been split into two parts)

 

 

 

Application Container Cloud defines two primary configuration descriptors – manifest.json and deployment.json, and each of them fulfill a specific purpose (more details here). In this case, we have defined the configuration using Developer Cloud service which in turn will override the ones in your application zip (if any) - refer to the documentation for more details

 

 

Confirmation screen

 

 

 

Check your application in Application Container Cloud

 

 

 

In the Deployment sub-section of the application details screen, notice that the required Service Bindings have been automatically wired

 

 

 

Test the application

The testing process remains the same – please refer to this section of the previous blog for details

 

Test the CI/CD flow

Make some code changes and push them to the Developer Cloud service Git repo. This should

  • Automatically trigger the build, which once successful will
  • Automatically trigger the deployment process, and
  • Redeploy the new application version to Application Container Cloud

 

 

**The views expressed in this post are my own and do not necessarily reflect the views of Oracle.