0% found this document useful (0 votes)
8 views

CI_CD Project with Github-Jenkins-Sonarqube-Docker

The document outlines a CI/CD project using GitHub, Jenkins, Sonarqube, and Docker to deploy a CSS project on AWS EC2 instances. It details the setup process, including creating repositories, configuring Jenkins with GitHub webhooks, and installing necessary software on EC2 instances. The final steps involve setting up Docker to run the application and ensuring that the CI/CD pipeline functions correctly for automated deployments.

Uploaded by

malikshah
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)
8 views

CI_CD Project with Github-Jenkins-Sonarqube-Docker

The document outlines a CI/CD project using GitHub, Jenkins, Sonarqube, and Docker to deploy a CSS project on AWS EC2 instances. It details the setup process, including creating repositories, configuring Jenkins with GitHub webhooks, and installing necessary software on EC2 instances. The final steps involve setting up Docker to run the application and ensuring that the CI/CD pipeline functions correctly for automated deployments.

Uploaded by

malikshah
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

Join now Sign in

CI/CD Project with Github-Jenkins-Sonarqube-Docker

CI/CD Project with Github-Jenkins-


Sonarqube-Docker
Powered by AI and the LinkedIn community

Bhim kumar + Follow

DevOps Engineer | AWS | Kubernetes | Linux |…


Published Aug 25, 2023

Jenkins CI/CD pipeline with GitHub webhook integration for Deploying CSS project on
EC2 instances using Docker and Sonarqube.

Understand the Architecture:

6
✔ Code commit will happen in github.

✔ Jenkins will Pull


Likethe code from github. Comment Share
✔ Sonarqube will Scan the code for code quality check.

✔ Docker will build and run the code.

✔ User will be able to access the application through browser.

Lets get started :

1. First download the free css project from the internet . link:

2. Create a repository in your github and clone that repo in your local machine.

3. Copy the project file in the cloned repo and push the code in you github.

4. By this way the downloaded code will be available in your github.

5. You can try any other method also to put the project code in your github.

6. Make sure the code is available in your github.

In Your AWS account :

1. Create 3 separate AWS EC2 instances, one for Docker , one for Sonarqube, one for jenkins. (
Go for t2.medium size , as it is having more memory which will handle the application easily ).

2. Name them with docker, jenkins, sonarqube while creating so that you dont get confused.

3. ssh into docker instance and install docker in it. open port 8085 in security group.

4. ssh into jenkins instance and install java 17 first and then install jenkins in it. Open port 8080
in security group other wise you will get error.

5. ssh into sonarqube instance and install java 17 first and then install sonarqube in it. Open
port 9000 in security group other wise you will get error while opening sonarqube. sonarqube
download link :

66. check and make sure they are active or running properly.

Like Comment
In Jenkins :

1. Login to jenkins through your browser with your instance ip and port 8080 and create a
freestyle project.

2. In SCM select git and give your github repo url.

3. In Build trigger select github hook trigger for gitscm polling.

4. Go to your github repo and in setting select webhook and in paylaod url give your jenkins url:
(your ip):8080/github-webhook/

5. click add webhook

6. your webhook is added.

Sonarqube : (we need to unzip the downloaded sonarqube zip file and start it)

1. Go to sonarqube instance and install unzip application or package to unzip any file. sudo apt
install unzip

2. Now type unzip (name of the sonarqube zip file that you have downloaded earlier) ex: unzip

Now to start the sonarqube type the following command : ( For LINUX )

ls

cd sonarqube-10.1.0.73491/

ls

cd bin

ls

cd linux-x86-64/
6

ls
Like Comment
./

./ console

Now go to browser and open the sonarqube : (sonarqube ip:9000)

-Default user and password both is admin

-Change with your own password

-we are logged in to the sonarqube

1. click Manually

2. Give any project name and key (same name for both) and main branch name=main

3. click setup

4. click with jenkins

5. github

6. configure analysis

7. continue - continue

8. other

9. copy the sonar somewhere.

10. finish

Go to admin ( top right corner )

1. my account
6

2. security
Like Comment
3. In generte token Name = any ; Type= global analysis token ; expire in 30 days.

4. click generate and copy the token somewhere.

In Jenkins :

Go to manage jenkins

Install sonarscanner and SSH2 Easy plugins both.

Now go to global tool configuration - Sonarqube scanner - give any name -install
automatically and save it.

Now go to configuration system - sonarqube server- copy the sonarqube app link(
ip:9000) and paste it . In server authentication token-add-jenkins- kind=secret ;
scope=global ; secret= paste the token that was copied from sonarqube ; Add it and
select the same token in server auth token. save it

Go to configure of your project :

1. In build steps: select- Execute sonarqube scanner

2. In analysis: paste the sonar that you have copied ex: sonar.project key= {name}

Now we need to setup docker and jenkins server so that jenkins server can access the
docker server easily:

In Docker Instance :

sudo su

nano /etc/ssh/sshd_config
6

Now in editor enable Public key Authentication yes ; Password Authentication yes ( keep it
same as I haveLike
written ). Comment
save it by typing ctrl+x

systemctl restart sshd

passwd ubuntu (give a password)

Now In jenkins instance :

ssh-keygen ( enter-enter)

ssh-copy-id ubuntu@ip of docker instance

give the password that you have set in docker instance.

Go to jenkins

1. Manage jenkins

2. system setting

3. server group centre

4. In server group list: -Name=Docker-Server-port=22-username=ubuntu-password= your docker


instance password

5. In server list :-give any server name-ip=docker instance ip

6. save it

In Github :

1. create a file name Dockerfile and type FROM nginxCOPY . /usr/share/nginx/html/


6

Like Comment
In Docker Instance:

1. mkdir website

2. cd website

3. sudo usermod -aG docker ubuntu

4. newgrp docker

In Jenkins :

Go to project config

1. In build step

2. Execute shellscr -r ./* ubuntu@(docker server ip):~/website

3. Remote Shellcd /home/ubuntu/websitedocker build -t cafe .docker run -d -p 8085:80 --


name=cafeapp cafe

Save it and make some changes in your github repo nd the build will start
automatically . After successfull build access it through browser :

<docker instance ip>:8085

✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌✌
If you found this article helpful, follow me and share the article with your friends.
#devops #project #share #linux #devopsjobs #content #docker #jenkins #awscloud

To view or add a comment, sign in

6
More articles by this author
Like Comment
Important Terminology and Minikube Installation Set up a Kubernetes c
Concepts of Terraform Process using Kubeadm
Dec 29, 2023 Sep 19, 2023 Sep 15, 2023
See all

Insights from the community

Server Architecture

What are the key skills and tools for serverless developers and engineers?

Information Technology

What are some cost-effective strategies for managing your technical architecture?

Cloud Computing

What are the best CI metrics to identify and resolve issues with your APIs?

Continuous Integration

How do you optimize Jenkins performance and scalability?

Cloud Development

How do you test and validate your cloud SDK code before deployment?

Software Testing

How can you test serverless architectures?


6

Like Comment
Show more

Others also viewed

Creating Azure Resource Manager (manual) Service Connection


Çiğdem KADAKOĞLU · 10mo

2024 predictions for open source software 🔮😎🥳


GitHub · 2w

Building a Full-Stack Web Application with Angular 15 and Spring Boot 3 from
SCRATCH (2023)
Attia Imed · 6mo

Building CI/CD Pipeline on AWS with Jenkins, SonarQube and Docker


Dayakar Reddy Duggimpudi · 5mo

Data Pipeline using Docker, Jenkins (CI/CD) and GitHub deployed on AWS
Atharva Kurle · 5mo

Day 28 Task: Jenkins Agents


Muhamad Kamran · 1mo

Show more

Explore topics
Sales

Marketing

Business Administration

HR Management

Content Management

6
Engineering

Soft Skills Like Comment


See All

© 2024 About

Accessibility User Agreement

Privacy Policy Cookie Policy

Copyright Policy Brand Policy

Guest Controls Community Guidelines

Language

Like Comment

You might also like