0% found this document useful (0 votes)
35 views10 pages

19.a Sample Continuous Delivery Project

The document outlines a simple Continuous Delivery (CD) project setup using Jenkins, Tomcat, and Nexus servers on virtual machines or AWS EC2 instances. It details the prerequisites, installation steps, and configuration for Jenkins jobs across development, QA, and UAT environments, including the use of Ansible for deployment automation. Additionally, it provides a deployment playbook for managing the installation and deployment of artifacts to Tomcat servers.

Uploaded by

Aslam Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views10 pages

19.a Sample Continuous Delivery Project

The document outlines a simple Continuous Delivery (CD) project setup using Jenkins, Tomcat, and Nexus servers on virtual machines or AWS EC2 instances. It details the prerequisites, installation steps, and configuration for Jenkins jobs across development, QA, and UAT environments, including the use of Ansible for deployment automation. Additionally, it provides a deployment playbook for managing the installation and deployment of artifacts to Tomcat servers.

Uploaded by

Aslam Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

XIX.

A Sample Continuous Delivery


Project.
It’s a very simple CD project but will give you an idea of Continuous Delivery
Pipeline. Everything has been kept to very minimum to reduce the complexity of
project.

PREREQUISITES:

Infrastructure can be setup with vagrant VM’s or AWS EC2 instances.


• One vm/ec2 instance Jenkins server (Ubuntu).
• Three vm’s/ec2 instances for deploying artefacts, tomcat node(Centos-6).
• One vm/ec2 instance for nexus server(Centos-6).

NOTE: If using EC2 instances, refer to the last page for Security group rules of Jenkins,
Nexus & Tomcat Nodes.

1. Jenkins server on ubuntu system: -


Vagrant vm or Ec2 instance.
• Install JDK 1.7 on Jenkins server
# sudo add-apt-repository ppa:openjdk-r/ppa
# sudo apt-get update
# sudo apt-get install openjdk-7-jdk

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
• Install Jenkins by following steps mentioned in below link.
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu

• Install git client and maven in Jenkins server.


# sudo apt-get install git
# sudo apt-get install maven

• Install Ansible on Jenkins server.


https://docs.ansible.com/ansible/intro_installation.html#latest-releases-via-apt-ubuntu

2. Tomcat node on centos: -

• Three tomcat nodes are required for Dev, QA and UAT deployment.
• Vagrant centos vm or Ec2 instance with Centos 6 OS
• Installation of tomcat and configuration would be taken care by ansible playbook, so we
just need three centos vm's.
• Please note its IP and credentials which we are going to add in ansible inventory file.

3. Nexus server on Centos.


• Nexus installation steps below.
• Create a centos vagrant vm/Ec2 instance with Centos 6 OS and login into it.

# yum install -y java-1.8.0-openjdk.x86_64 vim wget


# yum install -y java-1.8.0-openjdk-devel.x86_64
# export RUN_AS_USER=root
# wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
# sudo cp nexus-latest-bundle.tar.gz /usr/local/
# cd /usr/local
# sudo tar xvzf nexus-latest-bundle.tar.gz
# sudo ln -s nexus-2.13.0-01 nexus
# /usr/local/nexus/bin/nexus start

• From browser hit URL <Nexus server IP>:8081/nexus.


• Click login button and enter the credentials. (admin/admin123)
• Create hosted repository named “gameoflife-repo” with all default settings.

4. In total we should have below mentioned vm/instances ready.


• One vm/instance Jenkins server (Ubuntu).

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
• Three vm's for deploying artefacts, tomcat node(Centos-6).
• One vm for nexus server(Centos-6).

JENKINS DEV JOB SETUP.

1. Login to Jenkins server.


2. Prerequisites for the job execution mentioned below.
Install plugins: -
• git
• zentimestamp
• Parameterized Trigger plugin
• Nexus
• Ansible

Configure plugin: - Setup zentimestamp variable from Jenkins global settings page.
Manage Jenkins → Configure System → Global properties →
Check mark Date pattern for the BUILD_TIMESTAMP → Enter
value
yyyyMMddHHmm

3.Create Jenkins Jobs

Create three empty Jenkins job (Freestyle project) with below mentioned name and run all three
jobs. Once you run these three empty jobs it’s going to fail but that’s okay we want the jobs to
create workspace directory so that we can place our ansible script in those directories.
Job Names: - GameOfLifeOf_Dev
GameOfLifeOf_QA
GameOfLifeOf_UAT

4. Configure Dev job


As specified in the screenshots below.

Configure Jenkins job.

Configure GitHub plugin.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
Add build step.

Configure nexus plugin.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
Build step for ansible execution.

Playbook is given at the end of the page.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
5. Ansible code modifications:
• Login to Jenkins server and place ansible directory in the workspace of the job.
Workspace path specified below.
- /var/lib/Jenkins/workspace/GameofLife_Dev/

• Open gamer.yaml playbook and replace nexus server IP.

6. Execute the Jenkins dev job to validate.


Execution will happen in below phases
• Checkout git code from GitHub repository.
• Run maven build and unit test execution.
• Upload artefact to nexus server.
• Execution of ansible playbook to install java, tomcat on tomcat node and deploy artefacts
from nexus to tomcat node.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
JENKINS QA JOB SETUP.

1. Configure QA job same as Dev job, step 4 & 5.


• Make sure to edit the ansible inventory to specify QA tomcat node IP and nexus groupid
to QA
• Change Nexus artefact URL in gamer.yaml playbook: - In URL change Dev to QA.

Note: All the Jenkins job will have its own workspace directory. For QA job, the workspace path
would be as mentioned below.
- /var/lib/Jenkins/workspace/GameofLife_QA/

2. Adding QA automation script.


Add build step → Execute Shell → add below mentioned commands

echo “Executing test automation script.”


sleep 5
Note: - We do not have test automation script so we are imitating it.

3. Add post build step which will pass parameter to the UAT job
• Click Add post-build action → Trigger parameterized build on other properties
→ Click on Add Parameter
→ Predefined parameters
→ fill everything as shown in screenshot below.
→ Put a check mark on “Block until the triggered projects finish their builds.”

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
Visualpath Training & Consulting.
Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
JENKINS UAT JOB SETUP.

1. Configure UAT job, put a check mark on “This build is parameterized”.


2. Add three String parameters, fill in only “Name” section as shown in the screenshot.

3. Ansible execution for UAT job.


Add build step → Execute Shell → Add below mentioned content from screenshot.

4. Ansible Code modifications for UAT job.


• Place ansible directory in UAT workspace. Path for workspace mentioned below.
- /var/lib/Jenkins/workspace/GameofLife_QA/
• Make sure to edit the ansible inventory to specify UAT tomcat node IP.
• Change Nexus artefact URL in gamer.yaml playbook: - In URL change it to QA.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.
Deployment Playbook:

---
- hosts: tomcatservers
become: yes
tasks:
- name: Install EPEL-release
yum: name=epel-release state=present
- name: Install java_1.7
yum: name=java-1.7.0-openjdk.x86_64 state=present
- name: Install tomcat
yum: name=tomcat state=present
- name: Download latest gameoflife.war file
get_url: url=http://<Nexus
IP>:8081/nexus/content/repositories/gameoflife-repo/<Group ID
name>/{{time}}/{{build}}/{{gol_version}} dest=/tmp/ mode=755
- name: Stop tomcat service
service: name=tomcat state=stopped
- name: Copy artefact to tomcat folder
shell: cp /tmp/{{gol_version}} /var/lib/tomcat/webapps
- name: Delete link to existing gol version
file: path=/var/lib/tomcat/webapps/gameoflife state=absent
- name: Start tomcat service
service: name=tomcat state=started
- wait_for: path=/var/lib/tomcat/webapps/{{time}}-{{build}}
- name: Link latest GOL version
file: src=/https/www.scribd.com/var/lib/tomcat/webapps/{{time}}-{{build}}
dest=/var/lib/tomcat/webapps/gameoflife state=link
- name: Stop iptables
service: name=iptables state=stopped

Connect Dev and QA job together, use build pipeline plugin, execute the Dev job from
Build Pipeline plugin and see everything in action.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : [email protected], Website : www.visualpath.in.

You might also like