Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions AniketNote.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
1️⃣ Install Java 17 (Amazon Linux)

yum update -y
yum install java-17 -y
java -version
yum install git -y

Install Nginx :
yum install nginx -y
systemctl enable nginx
systemctl start nginx

Make Some changes in the File by using following commands and Set Permissions :

# 1️⃣ Go to Nginx web root
cd /usr/share/nginx/html

# 2️⃣ Copy actual web files from WebContent to root
sudo cp -r WebContent/* /usr/share/nginx/html/

# 3️⃣ Fix ownership so Nginx can read the files
sudo chown -R nginx:nginx /usr/share/nginx/html

# 4️⃣ Fix permissions so files are readable by everyone
sudo chmod -R 755 /usr/share/nginx/html

# 5️⃣ Restart Nginx to apply changes
sudo systemctl restart nginx

# 6️⃣ Verify the files and permissions
ls -l /usr/share/nginx/html



2️⃣ Jenkins Installation (no changes) or Use Jenkins.war file on apache tomcat

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum install -y jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins

3️⃣ Nginx, Git, curl

sudo amazon-linux-extras enable nginx1
sudo yum install -y nginx git curl
sudo systemctl enable nginx
sudo systemctl start nginx

4️⃣ Jenkins sudo privileges

sudo visudo

Add:
jenkins ALL=(ALL) NOPASSWD: ALL


5️⃣ CI Pipeline Setup (Jenkins)

Steps for CI (Compile / Build / Test):
Create a new Jenkins job → Name it Train-Ticket-CI → Type: Pipeline
Pipeline configuration → Pipeline script from SCM
SCM: Git
Repository URL: https://github.com/Wakekar/Train-Ticket-Reservation-System.git
Branch: main
Script Path: Jenkinsfile (your CI Jenkinsfile)


5️⃣ CD Deployment Permissions

sudo chown -R nginx:nginx /usr/share/nginx/html
sudo chmod -R 755 /usr/share/nginx/html
sudo systemctl restart nginx

6️⃣ CD Jenkinsfile (Amazon Linux, Java 17 compatible)

7️⃣ CD Pipeline Setup (Jenkins)

Steps:

Create a new Jenkins job → Name it Train-Ticket-CD → Type: Pipeline
Pipeline configuration → Pipeline script from SCM
SCM: Git
Repository URL: https://github.com/Wakekar/Train-Ticket-Reservation-System.git
Branch: main
Script Path: Jenkinsfile-cd

8️⃣ Optional: Trigger CD from CI

At the end of your CI Jenkinsfile:

stage('Trigger CD') {
steps {
build job: 'Train-Ticket-CD', wait: true
}
}

9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM amazoncorretto:17

WORKDIR /app

COPY target/*.war app.war

EXPOSE 8080

ENTRYPOINT ["java","-war","app.war"]
43 changes: 43 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pipeline {
agent any

tools {
jdk 'java' // must match JDK name in Manage Jenkins → Tools
}

stages {

stage('Checkout Source Code') {
steps {
// Jenkins automatically checks out the branch where Jenkinsfile exists
echo "Source code checked out successfully"
}
}

stage('Verify Java') {
steps {
sh '''
echo "JAVA_HOME=$JAVA_HOME"
java -version
'''
}
}

stage('Build') {
steps {
echo "Build stage goes here"
// Example (uncomment if using Maven):
// sh 'mvn clean package'
}
}
}

post {
success {
echo '✅ Pipeline executed successfully'
}
failure {
echo '❌ Pipeline failed'
}
}
}
77 changes: 77 additions & 0 deletions Jenkinsfile-Combine
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
pipeline {
agent any

tools {
jdk 'java'
}

stages {

// Stage: Install kubectl
stage('Install kubectl') {
steps {
sh '''
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
kubectl version --client
'''
}
}

// Stage: Checkout Source Code
stage('Checkout Source Code') {
steps {
echo "Cloning repository..."
git url: 'https://github.com/Wakekar/Train-Ticket-Reservation-System.git', branch: 'master'
}
}

// Stage: Verify Java
stage('Verify Java') {
steps {
sh '''
echo "JAVA_HOME=$JAVA_HOME"
java -version
'''
}
}

// Stage: Build
stage('Build') {
steps {
echo "Build stage goes here"
}
}

// Stage: Deploy to Kubernetes
stage('Deploy to Kubernetes') {
steps {
echo "Deploying application to Kubernetes..."
sh '''
kubectl apply -f train-ticket-app.yaml
kubectl rollout status deployment/train-ticket-app
'''
}
}

// Stage: Verify Deployment
stage('Verify Deployment') {
steps {
sh '''
kubectl get pods
kubectl get svc
'''
}
}
}

post {
success {
echo '✅ Pipeline executed successfully'
}
failure {
echo '❌ Pipeline failed'
}
}
}
41 changes: 41 additions & 0 deletions Jenkinsfile-cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pipeline {
agent any

stages {

stage('Checkout Source Code') {
steps {
echo "Cloning repository..."
git url: 'https://github.com/Wakekar/Train-Ticket-Reservation-System.git', branch: 'master'
}
}

stage('Deploy to Kubernetes') {
steps {
echo "Deploying application to Kubernetes..."
sh '''
kubectl apply -f train-ticket-app.yaml
kubectl rollout status deployment/train-ticket-app
'''
}
}

stage('Verify Deployment') {
steps {
sh '''
kubectl get pods
kubectl get svc
'''
}
}
}

post {
success {
echo "✅ Application successfully deployed to Kubernetes"
}
failure {
echo "❌ Kubernetes deployment failed"
}
}
}
41 changes: 41 additions & 0 deletions train-ticket-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: train-ticket-app
spec:
replicas: 2
selector:
matchLabels:
app: train-ticket-app
template:
metadata:
labels:
app: train-ticket-app
spec:
containers:
- name: train-ticket-app
image: <dockerhub-username>/train-ticket-app:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"

---
apiVersion: v1
kind: Service
metadata:
name: train-ticket-app-service
spec:
type: NodePort
selector:
app: train-ticket-app
ports:
- port: 8080
targetPort: 8080
nodePort: 30080