Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c13069b
Added Jenkinsfile
pp123456 Aug 28, 2025
24bed53
Added a.txt on develop branch
pp123456 Aug 28, 2025
bf61cd6
Added Jenkinsfile to develop
pp123456 Aug 28, 2025
a3cba3f
Created Dockerfile
rahulmg07 Aug 28, 2025
95021b9
Update Jenkinsfile
rahulmg07 Aug 28, 2025
b621bbb
Added 1.txt
pp123456 Aug 28, 2025
4f40a6e
Merging to local
pp123456 Aug 28, 2025
0e1cf53
Updated Jenkinsfile
rahulmg07 Aug 28, 2025
444e497
Added b.txt
pp123456 Aug 28, 2025
748ee6f
Merging for local
pp123456 Aug 28, 2025
08a62eb
Update Jenkinsfile
rahulmg07 Aug 28, 2025
a705f05
Added c.txt
pp123456 Aug 28, 2025
3550bef
Update Jenkinsfile
rahulmg07 Aug 28, 2025
26ec9cb
Update Jenkinsfile
rahulmg07 Aug 28, 2025
6a44fda
Update Jenkinsfile
rahulmg07 Aug 28, 2025
31e173e
Updated Jenkinsfile
rahulmg07 Aug 28, 2025
9488bd2
Created Dockerfile
rahulmg07 Aug 28, 2025
014413f
Added d.txt
pp123456 Aug 28, 2025
b75d9f5
..Merge branch 'master' of https://github.com/rahulmg07/basic-website
pp123456 Aug 28, 2025
97d77c9
Update Jenkinsfile
rahulmg07 Aug 28, 2025
234bf2b
Update Jenkinsfile
rahulmg07 Aug 28, 2025
f69a02a
Update Jenkinsfile
rahulmg07 Aug 28, 2025
f944048
Update Jenkinsfile
rahulmg07 Aug 28, 2025
ff1ec7e
Update Jenkinsfile
rahulmg07 Aug 28, 2025
ec2571e
Update Jenkinsfile
rahulmg07 Aug 28, 2025
1d1956d
Update Jenkinsfile
rahulmg07 Aug 28, 2025
30bbd40
Update Jenkinsfile
rahulmg07 Aug 28, 2025
16277f3
Update Jenkinsfile
rahulmg07 Aug 28, 2025
06e58e9
Update Jenkinsfile
rahulmg07 Aug 29, 2025
4b6a378
Update Jenkinsfile
rahulmg07 Aug 29, 2025
b53b1f2
Deleted d.txt
pp123456 Aug 29, 2025
1ab3c4d
Update Jenkinsfile
rahulmg07 Aug 29, 2025
28688fa
checking4
pp123456 Aug 29, 2025
c37c08e
merge branch 'master' of https://github.com/rahulmg07/basic-website
pp123456 Aug 29, 2025
dff73d2
Update Jenkinsfile
rahulmg07 Aug 29, 2025
d1688ef
deleted d.txt
pp123456 Aug 29, 2025
422bc62
Update Jenkinsfile
rahulmg07 Aug 29, 2025
0188688
deleted c.txt
pp123456 Aug 29, 2025
f8efc0e
Update Jenkinsfile
rahulmg07 Aug 29, 2025
a99ca00
Update Jenkinsfile
rahulmg07 Aug 29, 2025
fa34a8d
deleted b.txt
pp123456 Aug 29, 2025
0ddd973
Update Jenkinsfile
rahulmg07 Aug 29, 2025
961e796
Update Jenkinsfile
rahulmg07 Aug 29, 2025
bcb50da
..
pp123456 Aug 29, 2025
4918361
added b.txt
pp123456 Aug 29, 2025
82b07e2
added feature.txt
pp123456 Aug 29, 2025
25a9f24
Update Jenkinsfile
rahulmg07 Aug 29, 2025
0d73638
added feature2.txt
pp123456 Aug 29, 2025
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
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use Ubuntu as base image
FROM ubuntu:20.04

# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install Apache
RUN apt-get update && \
apt-get install -y apache2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Copy website files to Apache document root
COPY . /var/www/html/

# Set permissions
RUN chown -R www-data:www-data /var/www/html && \
chmod -R 755 /var/www/html

# Expose Apache port
EXPOSE 80

# Start Apache in foreground
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
105 changes: 105 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
pipeline {
agent any

environment {
IMAGE_NAME = 'website-app'
PROD_CONTAINER_NAME = 'website-prod'
PROD_PORT = '82'
}
stages {
stage('Checkout') {
steps {
echo "Checking out branch: ${env.BRANCH_NAME}"
checkout scm
}
}

stage('Validate') {
steps {
script {
echo "Validating repository structure..."
sh '''
if [ ! -f "index.html" ]; then
echo "Error: index.html not found!"
exit 1
fi
echo "Validation passed: index.html exists"
'''
}
}
}

stage('Build Docker Image') {
steps {
script {
echo "Building Docker image for branch: ${env.BRANCH_NAME}"
def imageTag = "${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
env.IMAGE_TAG = imageTag
sh """
docker build -t ${env.IMAGE_NAME}:${env.IMAGE_TAG} .
docker tag ${env.IMAGE_NAME}:${env.IMAGE_TAG} ${env.IMAGE_NAME}:${env.BRANCH_NAME}-latest
echo "DOCKER IMAGE BUILT SUCCESSFULLY: ${env.IMAGE_NAME}:${env.IMAGE_TAG}"
"""
}
}
}

stage('Test Build') {
steps {
script {
echo "Testing Docker image build..."

def testContainer = "test-container"
def networkName = "jenkins-test-network"

sh """
# Create network if it doesn't exist
docker network create ${networkName} 2>/dev/null || true

# stop and remove any leftover test container
docker rm -f ${testContainer} 2>/dev/null || true

# Run new test container on port 8081
docker run -d --name ${testContainer} --network ${networkName} -p 8081:80 ${env.IMAGE_NAME}:${env.IMAGE_TAG}
sleep 20

response=\$(docker run --rm --network ${networkName} curlimages/curl -s -o /dev/null -w "%{http_code}" http://${testContainer}:80 || echo "000")
if [ "\$response" != "200" ]; then
echo "Build test failed"
exit 1
else
echo "Build test passed"
fi
echo "Build test completed successfully"
"""
}
}
}

stage('Deploy to Production') {
when {
branch 'master'
}
steps {
script {
sh """
docker stop ${env.PROD_CONTAINER_NAME} 2>/dev/null || true
docker rm ${env.PROD_CONTAINER_NAME} 2>/dev/null || true
docker run -d --name ${env.PROD_CONTAINER_NAME} -p ${env.PROD_PORT}:80 --restart unless-stopped ${env.IMAGE_NAME}:${env.IMAGE_TAG}
"""
echo "Production deployed successfully on port ${env.PROD_PORT}"
}
}
}
}

post {
always {
sh '''
docker ps -aq --filter "name=test-container" | xargs -r docker rm -f || true
docker image prune -f || true
echo "Skipping cleanup for debugging"
'''
}
}
}
5 changes: 5 additions & 0 deletions a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<<<<<<< HEAD
checking
=======
text feature
>>>>>>> 961e796b7be2c779d3aa290074235e6929d758ae
1 change: 1 addition & 0 deletions feature.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checking122
1 change: 1 addition & 0 deletions feature2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checking8494