X

The Integration blog covers the latest in product updates, best practices, customer stories, and more.

  • August 6, 2019

CICD Implementation for OIC

Richard Poon
PMTS at Oracle

This blog is to share information on the CICD implementation for OIC and the instructions to setup and run the CICD scripts on a Linux machine environment.

In this implementation, bash shell scripts are used to support the backing up of integration artifacts from the source environment (OIC POD) to the repository (Bitbucket). Shell scripts are also used to retrieve the saved integration artifacts from the repository and deploy the integrations to a target environment (another OIC POD).

Following features are currently supported in this implementation:

1)   Export integrations and save the artifacts (IARs, connection json files) to the remote repository:

  • Allow user to either export all integrations, or only one or more integration(s) from the source OIC environment.
  • Commit/Push the exported integration artifacts to the repository.
  • Provide Summary Reports.

2)   Pull integration artifacts from the repository and either import or deploy the integrations to the target OIC environment:

  • Allows user to select one or more integrations to do import only, or to deploy the integrations to a target environment.

(To deploy an integration means to import IAR, update connections and activate the integration)

Pre-requisites

Following are the required setups in your Linux machine:

1)    JDK 1.8 Installation

Make sure to update your JDK to version 1.8 or higher

2)    Jenkins Installation

Ensure your Linux machine has access to a Jenkins instance.

Required Jenkins Plugins

Install the following Jenkins Plugins which are required by the CICD scripts:

        • Parameterized Trigger plugin
        • Delivery Pipeline plugin (version 1.3.2)
        • HTML Publisher plugin

3)   Git Client

Make sure to use Git client 2.7.4 or later in your Linux machine.

4)   Bitbucket/Github (repository)

Do the following to have access to the remote repository:

      • Setup SSH access to the remote repositories (Bitbucket/Github). 

A Bitbucket server administrator can enable SSH access to the Git repositories in Bitbucket server for you.  This allows your Bitbucket user to perform secure Git operations between your Linux machine and the Bitbucket server instance.

Note:    Bitbucket repository was used with this implementation.

      • Create the local repository by cloning the remote repository:

To create local repository, you can run the below commands from your <bitbucket_home>, where <bitbucket_home> is where you want your local repository to reside (i.e. /scratch/bitbucket):

        • cd   <bitbucket_home>
        • git clone  <bitbucket_ssh_based_url>

5)   Jq

You can download JQ (JSON Parser) from:

https://stedolan.github.io/jq/download/

Once downloaded, run the following commands:

      • rename ‘jq-linux64’ to ‘jq’
      • chmod  +x  jq
      • copy the ‘jq’ file to /usr/bin using sudo.

Note: 

It is required to have the minimal of the Git client and Jq utility to be installed on the same server where you are running the scripts.  Jenkins and Bitbucket repository can be on remote servers.

Scripts setup

Perform the following to setup on your Linux machine to run the bash shell scripts:

  • Create a new <cicd_home> directory in your local Linux machine (i.e. /scratch/cicd_home).

Note:  <cicd_home> is where all the CICD related files will reside.

  •  
  • Download the oic_cicd_files.zip file to your <cicd_home> directory.
  • Run unzip to extract the directories and files. 

Once unzipped, you should see the below file structure under your <cicd_home> directory:

  • From <cicd_home>, run the below command to ensure that you are using git version 2.21.0 or later:

> git  --version 

 

For CI (Continuous Integration)

Two shell scripts are provided for CI process:

export_integrations.sh

This script exports integrations (IARs along with the corresponding connection json files) from source OIC environment.  The script allows user to either export ALL integrations, or to export one or more specified integrations.

For exporting one or more integrations, under <cicd_home>/01_export_integrations directory, edit the config.json file and update to include the integration Identifier (code) and the version number that you want to backup, one integration per line in below json format:

[

      { "code": "<integration1_Id>", "version":  "<integration1_version>" }

      { "code": "<integration2_Id>", "version":  "<integration2_version>" }

      ..

]

For example:

 [

{ "code": "SAMPL_INCID_DETAI_FROM_SERVI_CLO", "version":  "01.00.0000" }

]

Note:    The above steps are not required if you want to export All integrations.  The config.json file will be created automatically by script.

push_to_repository.sh

This script utilizes the Git utility to Commit and Push integration artifacts to the remote Repository.  This allows developer to save the current working integrations, and to fall back to previous versions as need be.

 

For CD (Continuous Delivery)

Two shell scripts are provided for CD process:

pull_from_repository.sh

This script pulls the integration artifacts from the remote repository, and stores the artifacts under a local location.

deploy_integrations.sh

This script deploys integration(s) to target OIC environment. User has the option to only import the integrations, or to deploy the integrations (import IARs, update connections and activate integrations).

Perform the following steps to either import or deploy integrations:

1) Under <cicd_home>/04_Deploy_Integrations/config directory, edit the integrations.json file to include the below information of the integrations to be imported/deployed:

        •  
        • Integration Identifier (code) and the integration version number
        • Connection Identifier (code) of the related connections used by the integration.

For example:

     { "integrations":
        [
          {
               "code":"SAMPL_INCID_DETAI_FROM_SERVI_CLO",
                "version":"01.00.0000",
                "connections": [
                        { "code":"MY_REST_ENDPOINT_INTERFAC" },
                        { "code":"SAMPLE_SERVICE_CLOUD" }
                ]

            }

          ]
        }

 

2) Prior to deploying the integration, update the corresponding <connection_id>.json file to contain the expected values for the connection (i.e. WSDL URL, username, password etc).

For example:

SAMPLE_SERVICE_CLOUDE.json contains:

{
     "connectionProperties":[
          {
             "propertyGroup":"CONNECTION_PROPS",
             "propertyName":"targetWSDLURL",
             "propertyType":"WSDL_URL",
             "propertyValue":"<WSDL_URL_Value>"
           }
       ],
       "securityPolicy":"USERNAME_PASSWORD_TOKEN",
       "securityProperties":[
            {
                 "propertyGroup":"CREDENTIALS",
                 "propertyName":"username",
                 "propertyType":"STRING",
                 "propertyValue":"<user_name>"
            },
            {
                  "propertyGroup":"CREDENTIALS",
                  "propertyName":"password",
                  "propertyType":"PASSWORD",
                  "propertyValue":"<user_password>"
             }
          ]
     }

 

Import Jenkins Jobs

While you can create the Jenkins Jobs manually, you have the option to import the Jenkins jobs by using the jenkins_jobs.zip file.

To import Jenkins Jobs

1)   Download and unzip the jenkins_jobs.zip file to your <Jenkins_home>/.job directory. 

Where <jenkins_home> is the location where your Jenkins instance is installed

2)   Restart Jenkins server

3)   Once Jenkins server is restarted, login to Jenkins (UI) and:

        • Update all parameters for the below four Jobs as per your environment:
          • 01_Export_Integrations_and_Push
          • 02_Pull_Integrations_and_Deploy
          • 02a_Pull_Integrations_from_Repository
          • 02b_Deploy_Integrations_to_Target

For example:

GIT_INSTALL_PATH:         /user/local/git

        • Update the ‘Run_Location’ parameter in all other child jobs as per your environment (where the script used by each of the child job is located). 

For example: In the configuration of the Export_Integrations job:

RUN_LOCATION:   <cicd_home>/01_export_integrations

Where <cicd_home>/01_export_integrations is the full path to where the corresponding script (export_integrations.sh) resides, Note:  make sure the path does not contain ending ‘/’.

For the other Repository related child jobs (i.e Pull_from_Repository and Push_to_Repository, etc.) also update the GIT_INSTALL_PATH parameter to where your Git is being run from.

NOTE:

  • If there is no need to update the connection information for the Integrations, then the job 02_Pull_Integrations_and_Deploy can be used to pull Integration artifacts from the repository and also deploy the Integrations.
  • If the connection information needs to be updated (i.e. User name, User password, WSDL URL, etc), then:
  • First run 02a_Pull_Integrations_from_Repository to pull Integration artifacts from repository
  • Update the connection json files to contain relevant information
  • Call 02b_Deploy_Integrations_to_Target to deploy the Integrations

 

Create Jenkins Pipeline Views

To create Pipeline View, ensure to install Delivery Pipeline Plugin as mentioned earlier.

Perform the following steps:

1) Login to Jenkins

2) From Jenkins main screen, click on ‘+’ to Add a new View:

 

Enter view name: 01_OIC_CD_Pipeline_View

 

Go under Pipelines and click on Add to add Components:

Component Name:      OIC_CI_Pipeline                                      (or any relevant name for the view)

              Initial Job:     01_Export_Integrations_and_Push          (this is the root job in the pipeline)

Click Apply then OK.

Select the following options:

        • Enable start of new pipeline build
        • Enable rebuild
        • Show total build time
        • Theme (select ‘Contrast’)

(Keep default values for all other options)

The following view will be available for your Pipeline Job:

(Create CD view using the same steps above)

 

Reports

Reports are available for Export_IntegrationsPush_to_Repository and Deploy_Integrations jobs.

For Report to be displayed properly, we need to relax the Security Policy rule so that the Style codes in the HTML file can be executed.

Relax Content Security Policy rule

To relax this rule, from Jenkins, do the following:

        1. Manage Jenkins / Manage Nodes
        2. Click settings (gear icon)

​​

  1. click Script console on left and type in the following command:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

           
 

Click Run. If you see the 'Result:' output below "Result" header, then the protection is disabled successfully. Otherwise, click ‘Run’ again.


      

4. Restart the Jenkins server

 

To view Report for Export_Integrations job, for example:

Click on OIC Export Integrations Report link to view Report after the job is run:

 

                      

 

Steps to create Report

1) From the selected Job screen (i.e, Export_Integrations), click on Configure

2) Under Post-build Actions, add Publish HTML reports for the job

3) Use the following parameters (as example):

HTML directory to archive: ./

Index page[s]:  <the created html file>

Report title:      <enter proper title for the Report>

 

4) Click Apply then Save

 

Execute Jenkins Jobs

To run the CICD scripts, execute the below Jenkins pipeline jobs:

For CI:

  • 01_Export_Integrations_and_Push

Run this job to execute CI scripts. 

Wait for the parent job and its downstream jobs to complete running, then click on the child jobs, Export_Integraions or Push_to_Repository, and the Report link to see the results.

For CD:

     If there is no need to update connections, then run:

  • 02_Pull_Integrations_and_Deploy

Report is available under the Jenkins job Deploy_Integrations screen.

     If connection information needs to be updated prior to deploying the integrations, then first pull the integration artifacts from the repository:

  • 02a_Pull_Integrations_from_Repository

Update the connection json file(s) as need be, then deploy the integrations to target OIC environment by running:

  • 02b_Deploy_Integrations_to_Target

Report is available under the Jenkins job Deploy_Integrations_to_Target screen.

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.