Prerequisite for CICD Implementation For Oracle Integrations Cloud (OIC)

Richard Poon from Oracle gives an excellent article on setting up CICD in Oracle Integration Cloud Environment , however newbies like me may struggle to jump start with the blog. Hence I have tried compiling this pre-requisite to setup CICD. Once these steps are done we can use the scripts and Jenkins jobs from Richard.

Step 1:- Create Github account


Create a github account and create a repo in it.
copy the repo name featuring the ssh one, not the http one.
The Repo name shall look like :- git@github.com:myGit001/myRepo.git
Will be used in Step 8.

Step 2:- Create an OCI (Oracle cloud) account or login to the existing one.


Step 3:- Spin up Source and Target Integration Instances

a) First go to :- Identity and Federation

  • Create a compartment :- oicCompartment
  • Create a user :- <THIS ONE YOU WILL USE TO LOGIN TO OIC CONSOLE>
  • Create a group :- oci-integration-admins
  • Add user to the group.
  • Create a policy :- IntegrationGroupPolicy

allow group oci-integration-admins to manage integration-instance in compartment oicCompartment

b) Now go to :- Developer Services

  • Go to Integrations
  • Create Integration Instance.
  • Put a Display name :-
  • Choose Standard (For Demo Purpose) / Enterprise for Professional Purpose.
  • Anytime Standard can be made enterprise, so no worries.

Repeat the above process at least twice to create source and target OIC nodes.
Copy OIC Source Instance URL and paste in notepad++ or some editor.
Copy OIC Target Instance URL and paste in notepad++ or some editor.

You will need this during configuring jenkins jobs.


Step 4:- Creating VM for CICD :-

  • Go to Compute
  • Hit Create Instance.
  • Enter Name :- Example : devops001 | Choose Compartment
  • Save SSH Private Key to Login to the console.
  • Save the Public Key too.
  • Copy Public IP Address.
  • Login to terminal using : PuTTy / Mobaxterm
  • Use the SSH Key and user : opc

Once Logged in Linux Console :-
Open .bash_profile
add :-
export PS1='$(whoami)@$(hostname):$(pwd)>' to fix the prompt view
Now Login to root user using
sudo su -

Step 5:- Install Java in VM

execute : java -version
If -bash: java: command not found
This means Java is not present.

execute :-
yum -y update
This Update process may take some time. Around 10/15 minutes to complete may be.
Execute :- yum install java-1.8.0-openjdk
Verify using :- java -version
Get the java path :-
find /usr/lib/jvm/java-1.8* | head -n 3

Add JAVA_HOME to .bash_profile
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64
export JAVA_HOME
PATH=$PATH:$HOME/bin:$JAVA_HOME

exit and login again. Now
echo $JAVA_HOME
it will show the path
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64

Step 6:- Install Jenkins

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum -y install jenkins
if you encounter slowness in this process you may do :-
ps -ef|grep yum and kill the process by kill -9 <PID>
then retry yum -y install jenkins command again.

Now start Jenkins :-
service jenkins start

Once started in Web browser open Jenkins.
URL :- http://<PUBLIC_IP_OF_INSTANCE&gt;:8080

However it wont start because the VM is not allowing traffic from 8080.
We need to open it.

Open firewall:-
sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

Also we should add ingress rule in Default Security List for VCN:-

get initial jenkins password :-
cat /var/lib/jenkins/secrets/initialAdminPassword

go to admin user and setup the new password in Jenkins Web Console which is running on
http://<COMPUTE’s PUBLIC_IP>:8080.

now we will configure the jenkins user. The user details is in below file :-
grep jenkins /etc/passwd
jenkins:x:993:992:Jenkins Automation Server:/var/lib/jenkins:/bin/false
We will change the ‘/bin/false’ to ‘/bin/bash’ for this file.

Execute :
passwd jenkins
and enter password.

Lets login using jenkins user in linux.

Execute :
su -l jenkins
Execute :
vi .bash_profile
add
export PS1='$(whoami)@$(hostname):$(pwd)>'
save and exit the vi Editor.

Exit the jenkins linux user. We will comeback later.


Step 7:- Install / Update the git version

Enter the root user :-
sudo su -

Execute :
git --version
if version is not new then :-
Remove old version :-
yum remove git*

Else start installing git
Install new:-
yum -y install ttps://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm

Now check git --version

Step 8:- Connect Local repository to Remote Git Repository (Password less)

Login to jenkins user :-
su -l jenkins
Create SSH Key :-
ssh-keygen -t ed25519 -C "ENTER YOUR EMAIL HERE INSIDE QUOTES"
Start SSH Agent :-
eval ssh-agent -s
Add Key :-
ssh-add ~/.ssh/id_ed25519

Copy the Key to Notepad.

cd .ssh
cat id_ed25519.pub


Looks like :-
ssh-ed25519 <key> <email_id>

Login to Github.com Web account.

Go to Settings > SSH and GPG Keys >
Click New SSH Keys
Give a name. Ex: DevOps_Entry_Pass
Paste the key which you copied in Notepad.
Click Add Key.


Go Back to the Linux Console and Create two directory using Jenkins user.

mkdir cicd_demo cicd_scripts

full path : /var/lib/jenkins/cicd_demo
full path : /var/lib/jenkins/cicd_scripts

cicd_demo will be our local code repository.
cicd_scripts will be the directory where we will store the shell scripts which are to be used in Jenkins jobs.

now Execute :-
cd /var/lib/jenkins/cicd_demo

Initiate the Git repository:-

git init

connect remote repository (This you created in Step 1)to git repository.

git remote add origin git@github.com:<yourGitUserName>/<YourGitRepoName>

[Example : git remote add origin git@github.com:myGit001/myRepo.git]

** Ensure your remote git repository branch name is master not main.

Copy your remote repo into the local directory.

git pull origin master
(press y)

Test Git push now :-

echo "Hello from server" > newfile.txt

git add .

git status

git commit -m "commiting from new server"

git push origin master

Now check your remote repoisitory in github.com to see if the file you created is added or not.

Your local repo is ready.


Step 9:- Now lets get the scripts :-

cd /var/lib/jenkins/cicd_scripts

wget https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/df33e9df-2f02-4476-8691-38c6c5c876ca/File/fbfc2a43e640f87f68310b7f5d4f6c5e/oic_cicd_files.zip

unzip oic_cicd_files.zip

rm oic_cicd_files.zip

cd /var/lib/jenkins/jobs

wget https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/df33e9df-2f02-4476-8691-38c6c5c876ca/File/2ef4e89941d04783311a351fe3890115/jenkins_jobs.zip

unzip jenkins_jobs.zip

rm jenkins_jobs.zip


Go to root user and restart jenkins.

service jenkins restart

Then login to the jenkins web console again. You will be able to see the jobs.

Install Jenkins Plugins :-

Manage Jenkins > Manage Plugins > Available
Search and Install without restart:-

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

Step 10:- Now You can Configure The Scripts , Jobs and Pipelines reading Richard’s awesome Blog.

How Jenkins Look After Implementing

CI Pipeline
CD Pipeline
Source Server
Target Server

Bonus Tips :-

Content of jenkins directory can be migrated from One VM to Another.
Turn off Jenkins in Source and Destination VM.
In Source VM:-
cd /var/lib/jenkins
zip -r jenkins_bkp_server1.zip . [-r zips the hidden too]
Switch to root user.
vi /etc/ssh/sshd_config
Make PasswordAuthentication yes
ChallengeResponseAuthentication yes
systemctl restart sshd

In Destination VM:-
cd /var/lib/jenkins
zip -r jenkins_bkp_server2.zip .
copy it in some directory for future reference.
Switch to root user.
vi /etc/ssh/sshd_config
Make PasswordAuthentication yes
ChallengeResponseAuthentication yes
systemctl restart sshd

Now Copy from Source to Destination VM:-

jenkins@SourceServer:/var/lib/jenkins>
scp jenkins_bkp_server1.zip jenkins@<DESTINATION_PUBLIC IP>:/var/lib/jenkins/

Go to destination VM and unzip the file. Restart Jenkins in both the server and see.

Jenkins hosted from Source
Cloned Jenkins

Thanks for Reading.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.