Skip to content
Merged
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
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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!'
}
}
}


28 changes: 0 additions & 28 deletions jenkins/Jenkinsfile

This file was deleted.

12 changes: 12 additions & 0 deletions jenkins/scripts/deliver.bat
Original file line number Diff line number Diff line change
@@ -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
26 changes: 0 additions & 26 deletions jenkins/scripts/deliver.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/com/mycompany/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down
5 changes: 2 additions & 3 deletions src/test/java/com/mycompany/app/AppTest.java
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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());
}
}