About Configuring a CI/CD Pipeline

First, get your API ready. You should at least define its endpoints and download the scaffold that OMC generates for you. The scaffold represents a minimal application that you can use to make sure that your CI/CD process is working correctly before going ahead and writing and testing the code for your custom API.

When your API is ready and you can successfully push changes to the Git repository in your Developer Cloud Service project, it's time to set up CI/CD for the project.

Set Up the API in Oracle Mobile Hub

Create an API scaffold by defining the REST endpoints that your apps connect to. After you've completed the scaffold, you can download its definition to use as a starting point for your API code.

When defining the HTTP methods for your endpoints, you have the option of adding sample responses. Strictly speaking, the sample responses aren't required because you'll be writing code later that provides the real responses. However, you might want to enter some sample responses for testing the API before your custom code is ready.

  1. Log in to Oracle Mobile Hub and open the navigation panel.
  2. In the Applications section of the navigation panel, click APIs.
  3. Click New API and in the menu that opens, click API.
    The New API window opens.
  4. In the API Display Name field and the API Name field, enter a suitable name for your API.
  5. In the Short Description field, enter an appropriate description.
  6. If you have a RAML document for your API, upload it here.
  7. Click Create, and the page for your new API opens.
  8. Add HTTP resources. If you uploaded a RAML document you can skip this step.
    1. Click Endpoints then click New Resource to create the first endpoint and to define its HTTP methods.
    2. Continue defining the endpoints and HTTP methods for your API until all the endpoints are defined.
  9. Click Save.

Set Up the Backend

Create the backend that your API will use. The backend routes requests from your apps to the API, and provides authentication services.

  1. In the Oracle Mobile Hub navigation panel, click Backends, which opens the Backends page.
  2. Click New Backend and in the window that opens enter a suitable name in the Name field, then click Create.
    The backend configuration page opens. It has its own navigation panel, which is open at the Settings page.
  3. In the navigation panel for the configuration page, click APIs and in the page that opens, click Select APIs, which opens the API Catalog.
  4. In the catalog, find the card for the API that you created and click its + button. This associates that API with this backend.

Record Backend and Instance Details Information

Record information that you'll need when you configure the development tooling.

The information is used in a file called toolsConfig.json, and is required for authentication. It allows a script to connect to Oracle Mobile Hub and deliver code artifacts to it.

  1. In the Oracle Mobile Hub navigation panel, click Backends, which opens the Backends page.
  2. Select your backend and click Open.
  3. In the navigation panel, click Settings.
  4. Record the following information and copy it to a text file or other place where you can easily retrieve it later:
    • Client ID
    • Client Secret
    • Backend ID
    • Backend Name
    • Backend Version
    • Anonymous Key
  5. In the navigation panel, click Development to open the main page, then click Instance Details to open the Instance Details panel.
  6. Record the following information and keep it with the backend information that you recorded in a previous step:
    • Team Member App Client ID
    • Team Member App Client Secret

Set Up a Project in Oracle Developer Cloud Service

Create a project that includes a Git repository. Later, you'll configure the project to run a build whenever you push a commit to the repository.

Create a Project

Create a project that includes a Git repository.

  1. Log in to the Oracle Developer Cloud Service console, and click New Project.
  2. On the Project Details page, enter a name for your project and click Next.
  3. On the Template page, select Initial Repository and click Next.
  4. On the Project Properties page, accept the default values and click Finish to start the provisioning process.

After the project is provisoned, your screen should be similar to the following image:


The project summary page

Clone and Configure the Git Repository

Clone the repository to your local development system.

  1. Log in to Oracle Developer Cloud Service and navigate to your project page.
  2. Copy the HTTP address from the field for the repository for Git.
  3. Open a terminal window (on Linux or Mac) or the Git Bash terminal (on Windows), and create a new directory in a convenient location on your hard drive. Use a name for the directory that's appropriate for your project.
     mkdir <your-directory-name>
  4. Change to the directory and clone the repository, replacing the repository address in the sample with your own.
    cd <your-directory-name>
    git clone <your-repo-url>

    When you are prompted for a password, use the password that you use to log in to Oracle Developer Cloud Service.

  5. Change to the directory that was created by the cloning process.
    cd <your-directory-name>
  6. Set your name and email address for this project, and configure Git to store your credentials.
    git config user.name "<your-name>"
    git config user.email "<your-email-address>"
    git config credential.helper store

Create a New Build Job

Create a job that will run whenever you push code to the project's Git repository.

  1. Log in to Oracle Developer Cloud Service and navigate to your project page.
  2. In the navigation panel, click Build and in the page that opens, click New Job.
  3. Enter a name and select a software template then click Create Job.
  4. Click Add Source Control and select Git.
  5. In the Repository drop-down, select the Git repository that you want to use.
  6. Optional: If you are the only developer who pushes code to the repository, select Automatically perform build on SCM commit.

    If several people are working on the project and pushing code to the repository, then don't select this option. You can set up an SCM polling trigger instead, which you can do after you finish creating the build job.

  7. Click Save.

Configure the SCM Polling Trigger

You can set up a poll that checks for changes to the Git repository on a schedule that you define. If changes are detected, a build is started.

If you're the only developer who pushes code to the repository, then an immediate build is probably appropriate. However, when several people will be pushing code, you can set up a polling trigger that periodically checks for changes to the repository before starting a build.

To set up the SCM polling trigger, you use the crontab format to set a polling schedule. If you're not familiar with the crontab format, you can use the graphical interface to create the schedule.

The default schedule is every 30 minutes, represented by 0/30 * * * *. To set the schedule to run at 30 minutes past the hour every hour, use 30 * * * *.

  1. Log in to the Oracle Developer Cloud Service console, and open your project.
  2. In the navigation panel, click Build then select the build that you want to set the parameters for.
    The Build Settings page opens.
  3. Click Configure.
    The Job Configuration page opens.
  4. Click the gear icon The settings icon looks like a pair of gears. then click Triggers to open the Configure Build Triggers panel.
  5. Click the Add Trigger drop-down and select SCM Polling Trigger.
  6. Set the schedule and click Save.

Set Up the Build Parameters

Set up a string parameter and a password parameter to hold the user name and password for your Oracle Mobile Hub account.

Keep track of the names of these parameters because you'll need them later when you configure the developer tooling.

  1. Log in to the Oracle Developer Cloud Service console, and open your project.
  2. In the navigation panel, click Build then select the build that you want to set the parameters for.
    The Build Settings page opens.
  3. Click Configure.
    The Job Configuration page opens.
  4. Click the Build Parameters tab.
  5. Click the Add Build Parameter drop-down and select String Parameter.
  6. Enter a name for the user name parameter. For example devUser.
  7. In the Default Value field, enter your Oracle Mobile Hub user name. For example samir.developer@example.com.
  8. Click the Add Build Parameter drop-down and select Password Parameter.
  9. Enter a name for the password parameter such as devPassword.
  10. In the Default Value field, enter the password for your Oracle Mobile Hub user name.
  11. Click Save.

Configure the Unix Shell Builder

The shell builder is a Bash script that runs on the build system whenever a build is triggered. It installs dependencies then delivers your code to Oracle Mobile Hub.

The script runs against the source from the Git repository that you set up when you created the project in Oracle Developer Cloud Service. Note that if the script fails at any point, it exits with an error and no code is deployed.

  1. Log in to the Oracle Developer Cloud Service console, and open your project.
  2. In the navigation panel, click Build then select the build that you want to set the parameters for.
    The Build Settings page opens.
  3. Click Configure.
    The Job Configuration page opens.
  4. Click the Builders tab.
  5. Click the Add Builder drop-down and select Unix Shell Builder.
  6. In the Script field, enter the following script:
    export NODE_PATH=node-configurations/8.9/node_modules
    npm install
    cd omce-tools
    npm install
    cd node-configurations/8.9
    npm install
    cd ../..
    node omce-deploy ../toolsConfig.json -u $devUser -p $devPassword
  7. Click Save.

Download the JavaScript Scaffold

After you've created the API skeleton, the system creates a scaffold for the API code which you can download in a zip file.

The scaffold contains the initial structure and files for the implementation of the API, which you'll use as a starting point for your customizations. You need to extract the files and place them in your working directory.

  1. In Oracle Mobile Hub, open the API that you want the scaffold for.
  2. In the API navigation panel, click Implementation.
  3. Click JavaScript Scaffold, which downloads the scaffold file to your computer.
  4. Extract package.json, toolsConfig.json, and the .js file for your API to your working directory. It's the same directory that was created when you cloned the Git repository, and contains the .git directory.

Install and Configure Development Tooling

Oracle provides tools for uploading your custom API implementations to Oracle Mobile Hub from the command line. Add the tools to your Git repository so that they are available to your build script on Oracle Developer Cloud Service.

The tools are part of a download that also contains an Oracle Mobile Hub API that you can use for testing and debugging your custom API implementations on your development system. The API is not required for using the CI/CD pipeline. See the readme inside the omce-tools directory for instructions on using the API, which is called OracleMobileAPI.

The tools support two versions of Node.js: 6.10.0 and 8.9.x. In this procedure it's assumed that you're using version 8.9.4 or greater.

To install and configure the tooling:

  1. Go to https://www.oracle.com/technetwork/topics/cloud/downloads/amce-downloads-4478270.html and download Custom Code Test Tools version 18.3.1 or later. Note that the file names on this page still follow the legacy product names, but the code that they contain is up to date with the latest release. Similarly for the names of the tools inside the download.
  2. Open the file that you downloaded and extract the contents of the omce-tools/omce-tools directory to your working directory, the one that has your .git directory in it. For example, if your working directory is test-project, then extract the contents of omce-tools/omce-tools to test-project/omce-tools.
  3. Install the Node configuration: Change to the omce-tools/node-configurations/8.9 directory and run npm install.
  4. Install omce-tools on your system: Change to the omce-tools directory and run npm install -g.
  5. Create an environment variable called NODE_PATH and set it to node-configurations/8.9/node_modules.
  6. Make sure the tools are installed correctly. In the omce-tools directory, run node omce-test --version. The result should be 18.3.1.
  7. Update toolsConfig.json. When you downloaded the scaffold, it included the toolsConfig.json configuration file. Use the information that you recorded from the backend to replace the placeholder text in toolsConfig.json.