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
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# test
FROM bitnami/tomcat
FROM bitnami/tomcat:latest
ENV ALLOW_EMPTY_PASSWORD=yes
COPY addressbook.war /opt/bitnami/tomcat/webapps_default/addressbook.war
COPY target/*.war /opt/bitnami/tomcat/webapps_default/addressbook.war
73 changes: 64 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,75 @@
pipeline {
agent any

environment {
GIT_REPO = 'https://github.com/suhassg25/addressbook.git'
AWS_REGION = 'ap-south-1'
ECR_REPO_NAME = 'sample/jenkinspush'
ECR_PUBLIC_REPO_URI = '409171460696.dkr.ecr.ap-south-1.amazonaws.com/sample/jenkinspush'
IMAGE_TAG = 'latest'
AWS_ACCOUNT_ID = '409171460696'
IMAGE_URI = "${ECR_PUBLIC_REPO_URI}:${IMAGE_TAG}"
}

stages {
stage('Compile') {
steps {
sh 'mvn compile'
stage('Clone Repository') {
steps {
git url: "${GIT_REPO}", branch: 'master'
}
}

stage('Build') {
steps {
script {
sh '''
echo "Building Java application..."
mvn clean -B -Denforcer.skip=true package
'''
}
}
}

stage('Login to AWS ECR') {
steps {
script {
sh '''
echo "Logging into AWS ECR..."
aws ecr get-login-password --region ap-south-1 \
| docker login --username AWS --password-stdin 409171460696.dkr.ecr.ap-south-1.amazonaws.com
'''
}
}
}
stage('test') {
steps {
sh 'mvn test'

stage('Build Docker Image') {
steps {
script {
sh '''
echo "Building Docker image..."
docker build -t ${IMAGE_URI} .
'''
}
}
}
stage('package') {
steps {
sh 'mvn package'

stage('Push Docker Image to ECR') {
steps {
script {
sh '''
echo "Pushing Docker image to ECR..."
docker push ${IMAGE_URI}
'''
}
}
}
}

post {
success {
echo "Docker image pushed to ECR successfully and deployed."
}
failure {
echo "Pipeline failed."
}
}
}
13 changes: 10 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.edurekademo.tutorial</groupId>
<artifactId>addressbook</artifactId>
<packaging>war</packaging>
<version>2.0</version>
<version>3.4</version>
<name>Vaadin Addressbook example</name>

<properties>
Expand Down Expand Up @@ -79,7 +79,7 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<!-- The huge set of awesome Java libraries are available as such
for Vaadin developers, you should take the advantage of those. In this app
Expand Down Expand Up @@ -191,7 +191,14 @@
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>addressbook</finalName>
</build>
Expand Down