File tree Expand file tree Collapse file tree
main/java/com/mycompany/app
test/java/com/mycompany/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build
2+
3+ on :
4+ push :
5+ branches :
6+ - branch1
7+
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+
16+ - name : Set up JDK 17
17+ uses : actions/setup-java@v4
18+ with :
19+ java-version : ' 17'
20+ distribution : ' temurin'
21+
22+ - name : Build with Maven
23+ run : mvn package
Original file line number Diff line number Diff line change 1+ name : Deploy
2+
3+ on :
4+ push :
5+ branches :
6+ - branch1
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+
16+ - name : Set up JDK 17
17+ uses : actions/setup-java@v4
18+ with :
19+ distribution : ' temurin'
20+ java-version : ' 17'
21+
22+ - name : Build with Maven
23+ run : mvn package
24+
25+ - name : Set up Docker
26+ uses : docker/setup-buildx-action@v3
27+
28+ - name : Build Docker image
29+ run : docker build -t my-java-app .
30+
31+ - name : Run Docker container
32+ run : docker run -d -p 8081:8081 my-java-app
Original file line number Diff line number Diff line change 1+ name : Test
2+
3+ on :
4+ push :
5+ branches :
6+ - branch1
7+
8+ jobs :
9+ test :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+
16+ - name : Set up JDK 17
17+ uses : actions/setup-java@v4
18+ with :
19+ java-version : ' 17'
20+ distribution : ' temurin'
21+
22+ - name : Run Tests with Maven
23+ run : mvn test
Original file line number Diff line number Diff line change 1+ pipeline {
2+ agent any
3+ stages {
4+ stage(' Checkout' ) {
5+ steps {
6+ git branch : ' branch3' , url : ' https://github.com/Vanny253/simple-java-maven-app.git'
7+ }
8+ }
9+ stage(' Build' ) {
10+ steps {
11+ bat ' mvn clean package -DskipTests'
12+ }
13+ }
14+ stage(' Test' ) {
15+ steps {
16+ bat ' mvn test'
17+ }
18+ post {
19+ always {
20+ junit ' target/surefire-reports/*.xml' // This will show test results in Jenkins
21+ }
22+ }
23+ }
24+ stage(' Deliver' ) {
25+ steps {
26+ bat ' jenkins\\ scripts\\ deliver.bat'
27+ }
28+ }
29+ }
30+ post {
31+ always {
32+ echo ' Cleaning up workspace'
33+ deleteDir() // Clean up the workspace after the build
34+ }
35+ success {
36+ echo ' Build succeeded!!!'
37+ }
38+ failure {
39+ echo ' Build failed!'
40+ }
41+ }
42+ }
43+
44+
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ @ echo off
2+ REM Install your Maven-built JAR into the local repo
3+ echo Running Maven install into Jenkins's local repository…
4+ mvn jar:jar install:install help:evaluate -Dexpression=project.name
5+
6+ REM Read project name and version from the POM
7+ for /f " delims=" %%N in ('mvn -q -DforceStdout help:evaluate -Dexpression=project.name') do set " NAME = %%N "
8+ for /f " delims=" %%V in ('mvn -q -DforceStdout help:evaluate -Dexpression=project.version') do set " VERSION = %%V "
9+
10+ REM Run the built JAR so you can see its output in the console
11+ echo Launching JAR target\%NAME% -%VERSION% .jar…
12+ java -jar target\%NAME% -%VERSION% .jar
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 55
66public class App {
77
8- private static final String MESSAGE = "Hello from Spark Web Server!!!" ;
8+ private static final String MESSAGE = "Hello from Spark Web Server!!!Come " ;
99
1010 public App () {}
1111
Original file line number Diff line number Diff line change 11package com .mycompany .app ;
22
3- import org .junit .jupiter .api .Test ;
4-
53import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import org .junit .jupiter .api .Test ;
65
76/**
87 * Unit test for simple App.
@@ -20,6 +19,6 @@ public void testAppConstructor() {
2019 public void testAppMessage ()
2120 {
2221 App app = new App ();
23- assertEquals ("Hello from Spark Web Server!!!" , app .getMessage ());
22+ assertEquals ("Hello from Spark Web Server!!!Come " , app .getMessage ());
2423 }
2524}
You can’t perform that action at this time.
0 commit comments