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:
2) Pull integration artifacts from the repository and either import or deploy the integrations to the target OIC environment:
(To deploy an integration means to import IAR, update connections and activate the integration)
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:
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:
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.
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):
5) Jq
You can download JQ (JSON Parser) from:
https://stedolan.github.io/jq/download/
Once downloaded, run the following commands:
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.
Perform the following to setup on your Linux machine to run the bash shell scripts:
Note: <cicd_home> is where all the CICD related files will reside.
Once unzipped, you should see the below file structure under your <cicd_home> directory:
> git --version
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.
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:
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>"
}
]
}
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:
For example:
GIT_INSTALL_PATH: /user/local/git
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:
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:
(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 are available for Export_Integrations, Push_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:
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
To run the CICD scripts, execute the below Jenkins pipeline jobs:
For CI:
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:
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:
Update the connection json file(s) as need be, then deploy the integrations to target OIC environment by running:
Report is available under the Jenkins job Deploy_Integrations_to_Target screen.