diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000000..5fe46037df
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,23 @@
+name: Build
+
+on:
+ push:
+ branches:
+ - branch1
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+
+ - name: Build with Maven
+ run: mvn package
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000000..912f5291b1
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,32 @@
+name: Deploy
+
+on:
+ push:
+ branches:
+ - branch1
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ distribution: 'temurin'
+ java-version: '17'
+
+ - name: Build with Maven
+ run: mvn package
+
+ - name: Set up Docker
+ uses: docker/setup-buildx-action@v3
+
+ - name: Build Docker image
+ run: docker build -t my-java-app .
+
+ - name: Run Docker container
+ run: docker run -d -p 8081:8081 my-java-app
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000000..6ca9ea86de
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,23 @@
+name: Test
+
+on:
+ push:
+ branches:
+ - branch1
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+
+ - name: Run Tests with Maven
+ run: mvn test
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000000..4527f478c0
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,44 @@
+pipeline {
+ agent any
+ stages {
+ stage('Checkout') {
+ steps {
+ git branch: 'branch3', url: 'https://github.com/Vanny253/simple-java-maven-app.git'
+ }
+ }
+ stage('Build') {
+ steps {
+ bat 'mvn clean package -DskipTests'
+ }
+ }
+ stage('Test') {
+ steps {
+ bat 'mvn test'
+ }
+ post {
+ always {
+ junit 'target/surefire-reports/*.xml' // This will show test results in Jenkins
+ }
+ }
+ }
+ stage('Deliver') {
+ steps {
+ bat 'jenkins\\scripts\\deliver.bat'
+ }
+ }
+ }
+ post {
+ always {
+ echo 'Cleaning up workspace'
+ deleteDir() // Clean up the workspace after the build
+ }
+ success {
+ echo 'Build succeeded!!!'
+ }
+ failure {
+ echo 'Build failed!'
+ }
+ }
+}
+
+
diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile
deleted file mode 100644
index 966859677a..0000000000
--- a/jenkins/Jenkinsfile
+++ /dev/null
@@ -1,28 +0,0 @@
-pipeline {
- agent any
- options {
- skipStagesAfterUnstable()
- }
- stages {
- stage('Build') {
- steps {
- sh 'mvn -B -DskipTests clean package'
- }
- }
- stage('Test') {
- steps {
- sh 'mvn test'
- }
- post {
- always {
- junit 'target/surefire-reports/*.xml'
- }
- }
- }
- stage('Deliver') {
- steps {
- sh './jenkins/scripts/deliver.sh'
- }
- }
- }
-}
diff --git a/jenkins/scripts/deliver.bat b/jenkins/scripts/deliver.bat
new file mode 100644
index 0000000000..579aba2c4e
--- /dev/null
+++ b/jenkins/scripts/deliver.bat
@@ -0,0 +1,12 @@
+@echo off
+REM Install your Maven-built JAR into the local repo
+echo Running Maven install into Jenkins's local repository…
+mvn jar:jar install:install help:evaluate -Dexpression=project.name
+
+REM Read project name and version from the POM
+for /f "delims=" %%N in ('mvn -q -DforceStdout help:evaluate -Dexpression=project.name') do set "NAME=%%N"
+for /f "delims=" %%V in ('mvn -q -DforceStdout help:evaluate -Dexpression=project.version') do set "VERSION=%%V"
+
+REM Run the built JAR so you can see its output in the console
+echo Launching JAR target\%NAME%-%VERSION%.jar…
+java -jar target\%NAME%-%VERSION%.jar
diff --git a/jenkins/scripts/deliver.sh b/jenkins/scripts/deliver.sh
deleted file mode 100755
index 39a0636699..0000000000
--- a/jenkins/scripts/deliver.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env bash
-
-echo 'The following Maven command installs your Maven-built Java application'
-echo 'into the local Maven repository, which will ultimately be stored in'
-echo 'Jenkins''s local Maven repository (and the "maven-repository" Docker data'
-echo 'volume).'
-set -x
-mvn jar:jar install:install help:evaluate -Dexpression=project.name
-set +x
-
-echo 'The following command extracts the value of the element'
-echo 'within of your Java/Maven project''s "pom.xml" file.'
-set -x
-NAME=`mvn -q -DforceStdout help:evaluate -Dexpression=project.name`
-set +x
-
-echo 'The following command behaves similarly to the previous one but'
-echo 'extracts the value of the element within instead.'
-set -x
-VERSION=`mvn -q -DforceStdout help:evaluate -Dexpression=project.version`
-set +x
-
-echo 'The following command runs and outputs the execution of your Java'
-echo 'application (which Jenkins built using Maven) to the Jenkins UI.'
-set -x
-java -jar target/${NAME}-${VERSION}.jar
diff --git a/src/main/java/com/mycompany/app/App.java b/src/main/java/com/mycompany/app/App.java
index 1e603fc409..b6e3c0613e 100644
--- a/src/main/java/com/mycompany/app/App.java
+++ b/src/main/java/com/mycompany/app/App.java
@@ -5,7 +5,7 @@
public class App {
- private static final String MESSAGE = "Hello from Spark Web Server!!!";
+ private static final String MESSAGE = "Hello from Spark Web Server!!!Come";
public App() {}
diff --git a/src/test/java/com/mycompany/app/AppTest.java b/src/test/java/com/mycompany/app/AppTest.java
index 885be7c250..79db987259 100644
--- a/src/test/java/com/mycompany/app/AppTest.java
+++ b/src/test/java/com/mycompany/app/AppTest.java
@@ -1,8 +1,7 @@
package com.mycompany.app;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
@@ -20,6 +19,6 @@ public void testAppConstructor() {
public void testAppMessage()
{
App app = new App();
- assertEquals("Hello from Spark Web Server!!!", app.getMessage());
+ assertEquals("Hello from Spark Web Server!!!Come", app.getMessage());
}
}