Skip to content

Skruthikaa/JavaWebCalculator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI/CD Pipeline Setup using GitHub Actions, SonarQube, Nexus & Tomcat on AWS EC2

This guide walks through setting up a complete CI/CD pipeline using GitHub Actions with SonarQube for code quality, Nexus for artifact storage, and Tomcat for deployment, all hosted on AWS EC2 instances.

Step 1: Launch EC2 Instance for SonarQube

Purpose: Code Quality & Static Analysis

Go to AWS EC2 Console → Launch Instance

Select Ubuntu 22.04 LTS as AMI

Choose an instance type (Recommended: t2.medium or higher)

Select your Key Pair

Configure security group → allow Port 9000

Launch the instance

bd3d0e37bb79e26952ec8b6ad62c02d2_Screenshot%202025-11-10%20114032

Step 2: Connect to Instance & Install Java

Copy SSH command from AWS console

Connect from your terminal:

ssh -i <keypair.pem> ubuntu@

Install the latest version of Java:

sudo apt update sudo apt install openjdk-17-jdk -y java -version

b90baf362075adc011e70ffe90bcbb19_Screenshot%202025-11-10%20114154

Step 3: Install & Start SonarQube

Download and install SonarQube:

wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.4.1.87278.zip

unzip sonarqube-10.4.1.87278.zip

cd sonarqube-10.4.1.87278/bin/linux-x86-64

./sonar.sh start

5764be7edd8ce320afc70f107bb9292f_Screenshot%202025-11-10%20114702
Verify service is running:

./sonar.sh status

c3b75c74cfec32303a9bc50e40a43223_Screenshot%202025-11-10%20115011

Access SonarQube in browser:

http://:9000

Default credentials: admin / admin

Generate a Sonar Token for GitHub Actions.

6a22fcf5878ed08740df2a74e82f12f1_Screenshot%202025-11-10%20115206

Step 4: Launch EC2 Instance for Nexus

Purpose: Artifact Repository

Go to AWS EC2 Console → Launch Instance

Select Ubuntu 22.04 LTS as AMI

Choose an instance type

Select your Key Pair

Allow Port 8081

4931b516ce25a24d4dac61dbcb597929_Screenshot%202025-11-10%20115718
SSH into the instance and install Nexus:

wget https://download.sonatype.com/nexus/3/nexus-3.85.0-03-linux-x86_64.tar.gz

tar -xvf nexus-3.85.0-03-linux-x86_64.tar.gz

mv nexus-3.85.0-03 nexus

./nexus/bin/nexus start

2d2a7a85a9307a76b4ce0437b17545e6_Screenshot%202025-11-11%20103556

Access Nexus:

http://:8081

1f07d32dfe889238bc3c3d0e51df8d1f_Screenshot%202025-11-10%20121609

Step 5: Launch EC2 Instance for Tomcat

Purpose: Deployment Server

Go to AWS EC2 Console → Launch Instance

Select Ubuntu 22.04 LTS as AMI

Choose an instance type

Select your Key Pair

184f6e2ac9ae5cbc90f9777dd1306047_Screenshot%202025-11-10%20122814
SSH into instance and install Tomcat:

wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.112/bin/apache-tomcat-9.0.112.tar.gz

tar -xvzf apache-tomcat-9.0.112.tar.gz

cd apache-tomcat-9.0.112/bin

./startup.sh

cc2e7453551931caed70f677a0c723cd_Screenshot%202025-11-11%20103615
Configure a Tomcat Manager User:

Edit /etc/tomcat9/tomcat-users.xml and add:

Access Tomact:

36d52160cfe84e98b7ffe7d7e8f666e2_Screenshot%202025-11-11%20121654

Step 6: Configure GitHub Secrets

Go to GitHub Repository → Settings → Secrets and Variables → Actions

Click New Repository Secret and add the following:

Secret Name Description

SONAR_HOST_URL SonarQube Server URL

SONAR_TOKEN Generated Token

NEXUS_USER Nexus Username

NEXUS_PASS Nexus Password

TOMCAT_USER Tomcat Username

TOMCAT_PASS Tomcat Password

0b48c8b595449541085a683573e87db9_Screenshot%202025-11-10%20141358

Step 7: Create GitHub Actions Workflow

In your repository, create a new file:

.github/workflows/ci-cd.yml

Paste your pipeline YAML configuration and commit changes.

Navigate to the Actions tab — your CI/CD pipeline will start automatically on a new push to main.

d7f4d2a25e950d11475bc3b04af93094_Screenshot%202025-11-11%20103139 8922b8abd86185ad3ef6dc4d1efd744a_Screenshot%202025-11-11%20123241

Step 8: Verify Deployment

After successful execution:

SonarQube: Code Analysis Report

Nexus: Stored Build Artifacts

Tomcat: Deployed Application

fb44c8a41c24995cf25c592512bf8e37_Screenshot%202025-11-11%20103022 40ae50b0aebf16c4798d147d9b9aa428_Screenshot%202025-11-11%20103034 0b17a0f8dc2c0bec53abe675b491d02a_Screenshot%202025-11-11%20102918 212316d3056419e71f70c8cb331afef4_Screenshot%202025-11-11%20102951

Final Outcome

A fully automated CI/CD pipeline that:

Analyzes code with SonarQube

Stores artifacts in Nexus

Deploys to Tomcat automatically via GitHub Actions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%