From c285071165f1025c7e8bcffab4c70fa146d0c36b Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 07:38:40 +0530 Subject: [PATCH 01/16] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8d7640e7..03f0e1ff 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# sparkjava-war-example -Build war with maven and sparkjava framework +# java-war-example-HelloWorld +Build war with maven Steps: -1. Download a fresh [Tomcat 8 distribution](https://tomcat.apache.org/download-80.cgi) +1. Download a fresh [Tomcat 9 distribution](https://tomcat.apache.org/) 2. Clone this repository to your local machine 3. Run mvn package -4. Copy the generated `sparkjava-hello-world-1.0.war` to the Tomcat `webapps` folder +4. Copy the generated `java-war-example-HelloWorld .war` to the Tomcat `webapps` folder 5. Start Tomcat by running `bin\startup.bat` (or `bin\startaup.sh` for Linux) 5. Tomcat will automatically deploy the war -6. Open [http://localhost:8080/sparkjava-hello-world-1.0/hello](http://localhost:8080/sparkjava-hello-world-1.0/hello) in your browser +6. Open [http://localhost:8080/java-war-example-HelloWorld/hello](http://localhost:8080/java-war-example-HelloWorld/hello) in your browser From 2341cdd3eeb8bf4b13e31823021b2eeb8c43f02e Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 07:43:26 +0530 Subject: [PATCH 02/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 03f0e1ff..8e3ea2f4 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,6 @@ Steps: 2. Clone this repository to your local machine 3. Run mvn package 4. Copy the generated `java-war-example-HelloWorld .war` to the Tomcat `webapps` folder -5. Start Tomcat by running `bin\startup.bat` (or `bin\startaup.sh` for Linux) +5. Start Tomcat by running `bin\startup.bat` (or `bin\startup.sh` for Linux) 5. Tomcat will automatically deploy the war 6. Open [http://localhost:8080/java-war-example-HelloWorld/hello](http://localhost:8080/java-war-example-HelloWorld/hello) in your browser From c150525473731fcbc98c9a656ed3da6aacac1fef Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 08:57:27 +0530 Subject: [PATCH 03/16] Create Jenkinsfile --- Jenkinsfile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..ae77b9d2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +pipeline { + agent any + stages { + stage('Build') { + when { + anyOf { + branch 'production' + branch 'testing' + branch 'development' + } + } + steps { + sh 'mvn clean package' + } + } + stage('Test') { + when { + anyOf { + branch 'production' + branch 'testing' + branch 'development' + } + } + steps { + sh 'mvn test' + } + } + stage('Deploy to Production') { + when { + branch 'production' + } + steps { + sh 'mvn deploy' + } + } + } +} From d30bd74927cdc1168a782bd53e2741403f925f89 Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 08:58:22 +0530 Subject: [PATCH 04/16] Create Jenkinsfile --- Jenkinsfile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..ae77b9d2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +pipeline { + agent any + stages { + stage('Build') { + when { + anyOf { + branch 'production' + branch 'testing' + branch 'development' + } + } + steps { + sh 'mvn clean package' + } + } + stage('Test') { + when { + anyOf { + branch 'production' + branch 'testing' + branch 'development' + } + } + steps { + sh 'mvn test' + } + } + stage('Deploy to Production') { + when { + branch 'production' + } + steps { + sh 'mvn deploy' + } + } + } +} From 0ee27871171e2fa8bc35fb747bec438b8474165f Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 09:14:44 +0530 Subject: [PATCH 05/16] Create Jenkinsfile --- Jenkinsfile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..ae77b9d2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,37 @@ +pipeline { + agent any + stages { + stage('Build') { + when { + anyOf { + branch 'production' + branch 'testing' + branch 'development' + } + } + steps { + sh 'mvn clean package' + } + } + stage('Test') { + when { + anyOf { + branch 'production' + branch 'testing' + branch 'development' + } + } + steps { + sh 'mvn test' + } + } + stage('Deploy to Production') { + when { + branch 'production' + } + steps { + sh 'mvn deploy' + } + } + } +} From b3a7c8427e0c59c549838a471c17768d8c506f1d Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 09:43:43 +0530 Subject: [PATCH 06/16] Update Jenkinsfile --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index ae77b9d2..6c2821d8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,11 +26,19 @@ pipeline { } } stage('Deploy to Production') { + environment { + TOMCAT_URL = 'http://54.255.187.52:8080' + TOMCAT_USER = 'tomcat' + TOMCAT_PASSWORD = 'tomcat' + + } when { branch 'production' } + steps { sh 'mvn deploy' + sh "curl --upload-file /home/ubuntu/Projects/java-war-example-HelloWorld/target*.war ${TOMCAT_URL}/manager/deploy?path=sparkjava-hello-world-1.0 -u ${TOMCAT_USER}:${TOMCAT_PASSWORD}" } } } From 07c981ca696c181241814451354db7c033235872 Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 09:59:52 +0530 Subject: [PATCH 07/16] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6c2821d8..f8c90e4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,7 +27,7 @@ pipeline { } stage('Deploy to Production') { environment { - TOMCAT_URL = 'http://54.255.187.52:8080' + TOMCAT_URL = 'http://3.0.176.113:8080' TOMCAT_USER = 'tomcat' TOMCAT_PASSWORD = 'tomcat' From 964b6d4b0ce27a1e221f5f687407ce9e31d6a071 Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:05:21 +0530 Subject: [PATCH 08/16] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f8c90e4d..a4935ce2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { } } steps { - sh 'mvn clean package' + sh 'mvn package' } } stage('Test') { From e4e4e9eea8439ac1fbc18b0a83706b416c424efa Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:09:12 +0530 Subject: [PATCH 09/16] Delete Jenkinsfile --- Jenkinsfile | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index ae77b9d2..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,37 +0,0 @@ -pipeline { - agent any - stages { - stage('Build') { - when { - anyOf { - branch 'production' - branch 'testing' - branch 'development' - } - } - steps { - sh 'mvn clean package' - } - } - stage('Test') { - when { - anyOf { - branch 'production' - branch 'testing' - branch 'development' - } - } - steps { - sh 'mvn test' - } - } - stage('Deploy to Production') { - when { - branch 'production' - } - steps { - sh 'mvn deploy' - } - } - } -} From 5f8ceb3047890b539828c83707605888214d9a33 Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:09:33 +0530 Subject: [PATCH 10/16] Delete Jenkinsfile --- Jenkinsfile | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index ae77b9d2..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,37 +0,0 @@ -pipeline { - agent any - stages { - stage('Build') { - when { - anyOf { - branch 'production' - branch 'testing' - branch 'development' - } - } - steps { - sh 'mvn clean package' - } - } - stage('Test') { - when { - anyOf { - branch 'production' - branch 'testing' - branch 'development' - } - } - steps { - sh 'mvn test' - } - } - stage('Deploy to Production') { - when { - branch 'production' - } - steps { - sh 'mvn deploy' - } - } - } -} From 1181870e1c909fdc9f5614367edc1d5e5f0afd7c Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:11:58 +0530 Subject: [PATCH 11/16] Create Jenkinsfile --- Jenkinsfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..8bf849c3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,43 @@ +pipeline { + agent any + stages { + stage('Test') { + when { + anyOf { + branch 'production' + branch 'testing' + branch 'development' + } + } + steps { + sh 'mvn test' + } + } + stage('Build') { + when { + + branch 'production' + + } + steps { + sh 'mvn package' + } + } + stage('Deploy to Production') { + environment { + TOMCAT_URL = 'http://3.0.176.113:8080' + TOMCAT_USER = 'tomcat' + TOMCAT_PASSWORD = 'tomcat' + + } + when { + branch 'production' + } + + steps { + sh 'mvn deploy' + sh "curl --upload-file /home/ubuntu/Projects/java-war-example-HelloWorld/target*.war ${TOMCAT_URL}/manager/deploy?path=sparkjava-hello-world-1.0 -u ${TOMCAT_USER}:${TOMCAT_PASSWORD}" + } + } + } +} From 735c291c957d4e1312b70d7c77f2625a614cf64f Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 10:19:28 +0530 Subject: [PATCH 12/16] Delete Jenkinsfile --- Jenkinsfile | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index a4935ce2..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,45 +0,0 @@ -pipeline { - agent any - stages { - stage('Build') { - when { - anyOf { - branch 'production' - branch 'testing' - branch 'development' - } - } - steps { - sh 'mvn package' - } - } - stage('Test') { - when { - anyOf { - branch 'production' - branch 'testing' - branch 'development' - } - } - steps { - sh 'mvn test' - } - } - stage('Deploy to Production') { - environment { - TOMCAT_URL = 'http://3.0.176.113:8080' - TOMCAT_USER = 'tomcat' - TOMCAT_PASSWORD = 'tomcat' - - } - when { - branch 'production' - } - - steps { - sh 'mvn deploy' - sh "curl --upload-file /home/ubuntu/Projects/java-war-example-HelloWorld/target*.war ${TOMCAT_URL}/manager/deploy?path=sparkjava-hello-world-1.0 -u ${TOMCAT_USER}:${TOMCAT_PASSWORD}" - } - } - } -} From e55526441c8016862374e78f5d029d7e180b15bb Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 13:06:21 +0530 Subject: [PATCH 13/16] Update Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8bf849c3..12eeaa8a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,9 +35,7 @@ pipeline { } steps { - sh 'mvn deploy' - sh "curl --upload-file /home/ubuntu/Projects/java-war-example-HelloWorld/target*.war ${TOMCAT_URL}/manager/deploy?path=sparkjava-hello-world-1.0 -u ${TOMCAT_USER}:${TOMCAT_PASSWORD}" - } +echo "This is testing branch" } } } } From 543b86af37e36885e9f14585a38b8fe27017db91 Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 13:11:36 +0530 Subject: [PATCH 14/16] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 12eeaa8a..f056a072 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ pipeline { } steps { -echo "This is testing branch" } +echo "This is Development branch" } } } } From 7309523c2247e74142d33023f3950fe03f07a96a Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 13:32:50 +0530 Subject: [PATCH 15/16] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f056a072..f8fa9c2d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,9 +15,9 @@ pipeline { } stage('Build') { when { - - branch 'production' - + branch 'production' + branch 'testing' + branch 'development' } steps { sh 'mvn package' From 6541dad3062ed9f23140950e2164d4603df95286 Mon Sep 17 00:00:00 2001 From: himanshukingstorm <126673931+himanshukingstorm@users.noreply.github.com> Date: Sun, 2 Apr 2023 13:55:45 +0530 Subject: [PATCH 16/16] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f8fa9c2d..4babee58 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,10 +15,11 @@ pipeline { } stage('Build') { when { +anyOf{ branch 'production' branch 'testing' branch 'development' - } + } } steps { sh 'mvn package' }