From d073b9143c1d71603493f7db907712dfc889dce9 Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Mon, 9 Sep 2024 23:57:31 +0530
Subject: [PATCH 01/10] Created dummy file
---
dummy file | 1 +
1 file changed, 1 insertion(+)
create mode 100644 dummy file
diff --git a/dummy file b/dummy file
new file mode 100644
index 0000000..286d0b6
--- /dev/null
+++ b/dummy file
@@ -0,0 +1 @@
+just to create Pull request
From 79664e6f02b9731a8e471540f01880eab0e00c57 Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 10 Sep 2024 01:28:28 +0530
Subject: [PATCH 02/10] Delete dummy file
---
dummy file | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 dummy file
diff --git a/dummy file b/dummy file
deleted file mode 100644
index 286d0b6..0000000
--- a/dummy file
+++ /dev/null
@@ -1 +0,0 @@
-just to create Pull request
From e9b21246bb1682fb2fb9e19fa342acc750b55113 Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 10 Sep 2024 01:38:28 +0530
Subject: [PATCH 03/10] Create Empty_file
---
Empty_file | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Empty_file
diff --git a/Empty_file b/Empty_file
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/Empty_file
@@ -0,0 +1 @@
+
From 7544964e0afa3666c098441ef41d38bec6257e28 Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 17 Sep 2024 03:54:01 +0530
Subject: [PATCH 04/10] Update pom.xml
---
pom.xml | 148 ++++++++++++++++++++++++++++----------------------------
1 file changed, 75 insertions(+), 73 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4eeeb4f..f0078ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,75 +1,77 @@
- 4.0.0
- onlinebookstore
- onlinebookstore
- 0.0.1-SNAPSHOT
- war
-
- src/main/java
- onlinebookstore
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
- 2.3
-
-
- package
-
- copy
-
-
-
-
- com.github.jsimone
- webapp-runner
- 8.0.30.2
- webapp-runner.jar
-
-
-
-
-
-
-
- maven-compiler-plugin
- 3.11.0
-
- 1.8
- 1.8
-
-
-
- maven-war-plugin
- 3.2.1
-
- WebContent
-
-
-
-
-
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ onlinebookstore
+ onlinebookstore
+ 0.0.1-SNAPSHOT
+ war
+
+
+ src/main/java
+ onlinebookstore
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.3
+
+
+ package
+
+ copy
+
+
+
+
+ com.github.jsimone
+ webapp-runner
+ 8.0.30.2
+ webapp-runner.jar
+
+
+
+
+
+
+
+ maven-compiler-plugin
+ 3.11.0
+
+ 1.8
+ 1.8
+
+
+
+ maven-war-plugin
+ 3.2.1
+
+ WebContent
+
+
+
+ org.sonarsource.scanner.maven
+ sonar-maven-plugin
+ 4.0.0.4121
+
+
+
-
- org.postgresql
- postgresql
- 42.3.7
-
-
-
-
- mysql
- mysql-connector-java
- 8.0.28
-
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
-
\ No newline at end of file
+
+
+ org.postgresql
+ postgresql
+ 42.3.7
+
+
+ mysql
+ mysql-connector-java
+ 8.0.28
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+
+
+
From 5c76907e5f18e3608af155c570e222c62ef11fbe Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 17 Sep 2024 11:28:45 +0530
Subject: [PATCH 05/10] Update Jenkinsfile
---
Jenkinsfile | 77 ++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 64 insertions(+), 13 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 61d84f7..7ad6fa4 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,30 +1,81 @@
pipeline {
- agent any
+ agent { label 'dev' } // Specify the label of your Jenkins Slave. Modify 'dev' if you use a different label.
+
+ environment {
+ MAVEN_HOME = tool name: 'Maven' // Configure Maven installation. Ensure 'Maven' matches the name in Jenkins tool configuration.
+ SONARQUBE_SERVER = 'Sonar' // Define the SonarQube server ID. Replace 'Sonar' with your SonarQube server ID if different.
+ SONAR_SCANNER_HOME = tool name: 'SonarScanner' // Configure SonarQube Scanner installation. Ensure 'SonarScanner' matches the name in Jenkins tool configuration.
+ ARTIFACTORY_SERVER = 'Artifactory' // Define Artifactory server ID. Replace 'Artifactory' with your Artifactory server ID if different.
+ }
+
stages {
- stage ('checkout') {
+ stage('Checkout') {
steps {
- echo "This is checkout stage"
+ // Checkout the source code from your repository
+ // Modify the URL and branch if your repository or branch name changes
+ git url: 'https://github.com/shashank1553/java-onlinebookstore.git', branch: 'main'
}
}
- stage ('build') {
+
+ stage('Build') {
steps {
- echo "This is build stage "
+ // Build the Maven project
+ // Adjust Maven command if your build process requires additional options
+ sh "${MAVEN_HOME}/bin/mvn clean install"
}
}
- stage ('sonarscan') {
+
+ stage('SonarQube Analysis') {
steps {
- echo "This is sonarscan stage "
+ // Run SonarQube analysis
+ // Ensure the server ID matches your SonarQube configuration
+ withSonarQubeEnv(SONARQUBE_SERVER) {
+ sh "${MAVEN_HOME}/bin/mvn sonar:sonar"
+ }
}
- }
- stage ('push') {
+ }
+
+ stage('Deploy to Artifactory') {
steps {
- echo "This is push stage"
+ script {
+ // Upload artifacts to JFrog Artifactory
+ // Modify the 'serverId' and 'spec' according to your Artifactory configuration and repository structure
+ rtUpload (
+ serverId: ARTIFACTORY_SERVER,
+ spec: '''{
+ "files": [{
+ "pattern": "target/*.war", // Path to the artifact to upload. Modify if different.
+ "target": "maven-releases/myapp/" // Target repository path in Artifactory (Maven release repository). Modify as needed.
+ }]
+ }'''
+ )
+ }
}
}
- stage ('deploy') {
+
+ stage('Deploy to Tomcat') {
steps {
- echo "This is deploy stage "
+ script {
+ // Deploy the WAR file to Apache Tomcat server
+ // Adjust the Tomcat URL and credentials if your server details or credentials change
+ sh """
+ curl --upload-file target/*.war \\
+ "http://admin:123456@54.226.160.53:8080/manager/text/deploy?path=/myapp&update=true"
+ """
+ }
}
- }
+ }
+ }
+
+ post {
+ always {
+ cleanWs() // Clean the workspace after the build
+ }
+ success {
+ echo "Build, Analysis, and Deployment succeeded!"
+ }
+ failure {
+ echo "Build failed. Check the logs!"
+ }
}
}
From 3c157f0ff486d666b1e7b3ca905a0190fb42000c Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 17 Sep 2024 14:23:18 +0530
Subject: [PATCH 06/10] Update Jenkinsfile
---
Jenkinsfile | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 7ad6fa4..e192035 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -12,7 +12,6 @@ pipeline {
stage('Checkout') {
steps {
// Checkout the source code from your repository
- // Modify the URL and branch if your repository or branch name changes
git url: 'https://github.com/shashank1553/java-onlinebookstore.git', branch: 'main'
}
}
@@ -20,7 +19,6 @@ pipeline {
stage('Build') {
steps {
// Build the Maven project
- // Adjust Maven command if your build process requires additional options
sh "${MAVEN_HOME}/bin/mvn clean install"
}
}
@@ -28,7 +26,6 @@ pipeline {
stage('SonarQube Analysis') {
steps {
// Run SonarQube analysis
- // Ensure the server ID matches your SonarQube configuration
withSonarQubeEnv(SONARQUBE_SERVER) {
sh "${MAVEN_HOME}/bin/mvn sonar:sonar"
}
@@ -39,12 +36,11 @@ pipeline {
steps {
script {
// Upload artifacts to JFrog Artifactory
- // Modify the 'serverId' and 'spec' according to your Artifactory configuration and repository structure
rtUpload (
serverId: ARTIFACTORY_SERVER,
spec: '''{
"files": [{
- "pattern": "target/*.war", // Path to the artifact to upload. Modify if different.
+ "pattern": "target/onlinebookstore.war", // Path to the artifact to upload. Modify if different.
"target": "maven-releases/myapp/" // Target repository path in Artifactory (Maven release repository). Modify as needed.
}]
}'''
@@ -57,10 +53,8 @@ pipeline {
steps {
script {
// Deploy the WAR file to Apache Tomcat server
- // Adjust the Tomcat URL and credentials if your server details or credentials change
sh """
- curl --upload-file target/*.war \\
- "http://admin:123456@54.226.160.53:8080/manager/text/deploy?path=/myapp&update=true"
+ curl -u : --upload-file target/onlinebookstore.war "http://35.171.26.114:8081/artifactory/maven-releases/myapp/"
"""
}
}
From 97c20fe681626d36d396f713264b60f7f7ce0144 Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 17 Sep 2024 14:55:47 +0530
Subject: [PATCH 07/10] Update Jenkinsfile
---
Jenkinsfile | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index e192035..a09d788 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -2,10 +2,10 @@ pipeline {
agent { label 'dev' } // Specify the label of your Jenkins Slave. Modify 'dev' if you use a different label.
environment {
- MAVEN_HOME = tool name: 'Maven' // Configure Maven installation. Ensure 'Maven' matches the name in Jenkins tool configuration.
- SONARQUBE_SERVER = 'Sonar' // Define the SonarQube server ID. Replace 'Sonar' with your SonarQube server ID if different.
- SONAR_SCANNER_HOME = tool name: 'SonarScanner' // Configure SonarQube Scanner installation. Ensure 'SonarScanner' matches the name in Jenkins tool configuration.
- ARTIFACTORY_SERVER = 'Artifactory' // Define Artifactory server ID. Replace 'Artifactory' with your Artifactory server ID if different.
+ MAVEN_HOME = tool name: 'Maven' // Ensure 'Maven' matches the name in Jenkins tool configuration.
+ SONARQUBE_SERVER = 'Sonar' // Define the SonarQube server ID.
+ SONAR_SCANNER_HOME = tool name: 'SonarScanner' // Ensure 'SonarScanner' matches the name in Jenkins tool configuration.
+ ARTIFACTORY_SERVER = 'Artifactory' // Define Artifactory server ID.
}
stages {
@@ -40,8 +40,8 @@ pipeline {
serverId: ARTIFACTORY_SERVER,
spec: '''{
"files": [{
- "pattern": "target/onlinebookstore.war", // Path to the artifact to upload. Modify if different.
- "target": "maven-releases/myapp/" // Target repository path in Artifactory (Maven release repository). Modify as needed.
+ "pattern": "target/onlinebookstore.war", // Path to the artifact to upload
+ "target": "maven-releases/onlinebookstore/" // Target repository path in Artifactory
}]
}'''
)
@@ -54,7 +54,7 @@ pipeline {
script {
// Deploy the WAR file to Apache Tomcat server
sh """
- curl -u : --upload-file target/onlinebookstore.war "http://35.171.26.114:8081/artifactory/maven-releases/myapp/"
+ curl -u admin:Admin12345 --upload-file target/onlinebookstore.war "http://35.171.26.114:8081/artifactory/maven-releases/onlinebookstore/"
"""
}
}
From 1bf50af20d27a16900dce0027a68b106017c6d98 Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 17 Sep 2024 15:08:19 +0530
Subject: [PATCH 08/10] Update Jenkinsfile
---
Jenkinsfile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index a09d788..327d887 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -6,6 +6,7 @@ pipeline {
SONARQUBE_SERVER = 'Sonar' // Define the SonarQube server ID.
SONAR_SCANNER_HOME = tool name: 'SonarScanner' // Ensure 'SonarScanner' matches the name in Jenkins tool configuration.
ARTIFACTORY_SERVER = 'Artifactory' // Define Artifactory server ID.
+ SONAR_TOKEN = 'sqa_bcb97e97554c1eeff5b2a5cd9c0a23d2d59b749b' // SonarQube token
}
stages {
@@ -27,7 +28,7 @@ pipeline {
steps {
// Run SonarQube analysis
withSonarQubeEnv(SONARQUBE_SERVER) {
- sh "${MAVEN_HOME}/bin/mvn sonar:sonar"
+ sh "${MAVEN_HOME}/bin/mvn sonar:sonar -Dsonar.login=${SONAR_TOKEN}"
}
}
}
From fa7df78ac4485b8c84424024a490cd9987d770be Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 17 Sep 2024 15:10:00 +0530
Subject: [PATCH 09/10] Update pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index f0078ce..094ce80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
org.sonarsource.scanner.maven
sonar-maven-plugin
- 4.0.0.4121
+ 4.0.0.4121
From 88854686be93db66ca0cd56a525671ccd4e4a240 Mon Sep 17 00:00:00 2001
From: shashank1553 <116108268+shashank1553@users.noreply.github.com>
Date: Tue, 17 Sep 2024 16:22:36 +0530
Subject: [PATCH 10/10] Update pom.xml
---
pom.xml | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 094ce80..eb75375 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
org.apache.maven.plugins
maven-dependency-plugin
- 2.3
+ 3.6.0
package
@@ -35,6 +35,7 @@
+ org.apache.maven.plugins
maven-compiler-plugin
3.11.0
@@ -43,10 +44,11 @@
+ org.apache.maven.plugins
maven-war-plugin
- 3.2.1
+ 3.3.1
- WebContent
+ src/main/webapp
@@ -71,7 +73,8 @@
javax.servlet
javax.servlet-api
- 3.1.0
+ 4.0.1
+ provided