Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2d6e534
Update README.md
vikas0105 Dec 22, 2023
dfb9bca
Update README.md
vikas0105 Dec 24, 2024
8e85ece
Create jenkinsfile_parcel
vinayak432 Dec 3, 2025
a6ca133
Update jenkinsfile_parcel
vinayak432 Dec 3, 2025
2f155e5
Update jenkinsfile_parcel
vinayak432 Dec 3, 2025
eedcf30
Add files via upload
vinayak432 Dec 3, 2025
0632017
Rename jenkinsfile_parcel (1).txt to jenkinsfile_parcel.txt
vinayak432 Dec 3, 2025
5ff3a49
Update jenkinsfile_parcel
vinayak432 Dec 3, 2025
e9cc472
Update and rename jenkinsfile_parcel.txt to jenkinsfile_parcel
vinayak432 Dec 3, 2025
a8dea03
Update jenkinsfile_parcel
vinayak432 Dec 3, 2025
e55cc94
Update jenkinsfile_parcel
vinayak432 Dec 3, 2025
b37b52b
Update jenkinsfile_parcel
vinayak432 Dec 3, 2025
b21f859
Update jenkinsfile_parcel
vinayak432 Dec 3, 2025
f75eaaa
Merge branch 'main' into feature-1
vinayak432 Dec 5, 2025
f13e317
Update jenkinsfile_parcel
vinayak432 Dec 5, 2025
47df26e
Update jenkinsfile_parcel
vinayak432 Dec 6, 2025
cf4a9dd
Create parcel_booking_lib
vinayak432 Dec 8, 2025
aa90fee
Create parcel_booking_library
vinayak432 Dec 8, 2025
c0dbd8c
Update parcel_booking_library
vinayak432 Dec 8, 2025
be47a42
Update parcel_booking_library
vinayak432 Dec 8, 2025
fd8c4ed
Update parcel_booking_library
vinayak432 Dec 8, 2025
a1b6179
Update parcel_booking_library
vinayak432 Dec 8, 2025
34ea29d
Update parcel_booking_library
vinayak432 Dec 8, 2025
7990311
Update parcel_booking_library
vinayak432 Dec 8, 2025
358f3ef
Update parcel_booking_library
vinayak432 Dec 8, 2025
d75f947
Update parcel_booking_lib
vinayak432 Dec 8, 2025
74b91e1
Update parcel_booking_library
vinayak432 Dec 8, 2025
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
123 changes: 0 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,124 +1 @@
===========================================================================================================================================================================
============================================================================================================================================================================
Shell script to setup the environment.

#!/bin/bash
set -e
echo "Starting Maven project setup..."

# Step 1: Install Java 17
if ! java -version &>/dev/null; then
echo "Installing Java 17..."
sudo apt update
sudo apt install -y openjdk-17-jdk
else
echo "Java is already installed:"
java -version
fi

# Set JAVA_HOME
JAVA_HOME_PATH=$(dirname $(dirname $(readlink -f $(which java))))
if ! grep -q "JAVA_HOME=$JAVA_HOME_PATH" /etc/environment; then
echo "Setting JAVA_HOME..."
echo "JAVA_HOME=$JAVA_HOME_PATH" | sudo tee -a /etc/environment
echo "export JAVA_HOME=$JAVA_HOME_PATH" | sudo tee -a /etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' | sudo tee -a /etc/profile
source /etc/profile
echo "JAVA_HOME set to $JAVA_HOME_PATH"
else
echo "JAVA_HOME is already set."
fi

# Step 2: Install Maven
if ! mvn -version &>/dev/null; then
echo "Installing Maven..."
sudo apt install -y maven
else
echo "Maven is already installed:"
mvn -version
fi
echo "Environment setup completed. You can now build and run the application manually."
==============================================================================================================================================================================
Build the project manually
mvn clean install

Run the application manually
mvn spring-boot:run
OR
java -jar target/simple-parcel-service-app-1.0-SNAPSHOT.jar
==============================================================================================================================================================================

name: Build, Deploy, and Run

on:
push:
branches:
- main
pull_request:

jobs:
build-and-run:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout code
- name: Checkout Code
uses: actions/checkout@v4

# Step 2: Set up Java 17
- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: '17'

# Step 3: Set up Maven
- name: Set up Maven
uses: actions/setup-java@v3
with:
distribution: 'maven'

# Step 4: Build the project
- name: Build with Maven
run: mvn clean package

# Step 5: Upload the built JAR as an artifact
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: built-jar
path: target/simple-parcel-service-app-1.0-SNAPSHOT.jar

# Step 6: Run the Spring Boot application
- name: Run Application
run: |
nohup mvn spring-boot:run &
sleep 15 # Allow time for the app to fully start

# Step 7: Validate App is Running
- name: Validate App is Running
run: |
echo "Waiting for the app to start..."
sleep 15 # Allow some time for the Spring Boot app to fully start
echo "Checking if the app is running..."
RESPONSE=$(curl --write-out "%{http_code}" --silent --output /dev/null http://localhost:8080)
if [ "$RESPONSE" -eq 200 ]; then
echo "The app is running successfully!"
else
echo "The app failed to start. HTTP response code: $RESPONSE"
exit 1
fi

# Step 8: Wait for 5 minutes
- name: Wait for 5 minutes
run: |
echo "App has been running for 5 minutes. Waiting..."
sleep 300 # Wait for 5 minutes (300 seconds)

# Step 9: Gracefully Stop Spring Boot App
- name: Gracefully Stop Spring Boot App
run: |
echo "Stopping the app gracefully..."
mvn spring-boot:stop
============================================================================================================================================================================


72 changes: 72 additions & 0 deletions jenkinsfile_parcel
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
pipeline {
agent { label 'java' }
// agent any

tools {
jdk 'JDK17'
maven 'maven'
}

stages {

stage('Checkout') {
steps {
git branch: 'feature-1', url: 'https://github.com/vinayak432/Parcel-service.git'
}
}

stage('Build') {
steps {
sh 'mvn clean package -DskipTests=false'
}
}
// simple-parcel-service-app-1.0-SNAPSHOT.jar
stage('Push the artifacts into JFrog Artifactory') {
steps {
script {
// Define WAR file path
def WAR_FILE = "${env.WORKSPACE}/target/simple-parcel-service-app-1.0-SNAPSHOT.jar"

// Current timestamp
def currentDate = new java.text.SimpleDateFormat("yyyy-MM-dd_HH-mm").format(new Date())

// Path inside Artifactory
def targetPath = "feature_release1/${currentDate}/"

rtUpload(
serverId: "jfrog",
spec: """{
"files": [
{
"pattern": "${WAR_FILE}",
"target": "${targetPath}"
}
]
}"""
)
}
}
}


//stage('Archive Artifact') {
// steps {
// archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
// }
//}

stage('Run Application') {
steps {
sh 'mvn spring-boot:run'

dir('/var/lib/jenkins/workspace/Parcel_service_feature-1/target') {
sh """
// nohup java -jar simple-parcel-service-app-1.0-SNAPSHOT.jar > app.log 2>&1 &
// echo "Application started"
"""
}
}
}

}
}
34 changes: 34 additions & 0 deletions parcel_booking_lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@Library('pipeline_library') _

pipeline {
agent { label 'java' }

stages {
stage('Library-Demo') {
steps {
echo 'Executing a shared lib function'
sayHello 'Devops- parcel booking'
}
}

stage('Checkout') {
steps {
script {
sh("""
rm -rf Parcel-service
git clone https://github.com/vinayak432/Parcel-service.git
ls -ltr
""")
}
}
}

stage('Build') {
steps {
script {
build 'install'
}
}
}
}
}
75 changes: 75 additions & 0 deletions parcel_booking_library
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@Library('pipeline_library') _

pipeline {
agent { label 'java' }

stages {
stage('Library-Demo') {
steps {
echo 'Executing a shared lib function'
sayHello 'Devops- parcel booking'
}
}
stage('Checkout') {
steps {
script {
sh("""
rm -rf Parcel-service
git clone https://github.com/vinayak432/Parcel-service.git
ls -ltr
""")
}
}
}
stage('Build') {
steps {
script {
build 'package'
}
}
}
stage('Push the artifacts into JFrog Artifactory') {
steps {
script {
// Define WAR file path
def WAR_FILE = "${env.WORKSPACE}/target/simple-parcel-service-app-1.0-SNAPSHOT.jar"
//${env.WORKSPACE}/Parcel-service/target/simple-parcel-service-app-1.0-SNAPSHOT.jar

//def WAR_FILE = "/home/slave1/workspace/parcel_booking_library_feature-1/target/simple-parcel-service-app-1.0-SNAPSHOT.jar"
// /home/slave1/workspace/parcel_booking_library_feature-1/target
// Current timestamp
def currentDate = new java.text.SimpleDateFormat("yyyy-MM-dd_HH-mm").format(new Date())

// Path inside Artifactory
def targetPath = "feature_release1/${currentDate}/"

rtUpload(
serverId: "jfrog",
spec: """{
"files": [
{
"pattern": "${WAR_FILE}",
"target": "${targetPath}"
}
]
}"""
)
}
}
}

stage('Run Application') {
steps {
sh 'mvn spring-boot:run'

dir('/var/lib/jenkins/workspace/Parcel_service_feature-1/target') {
sh """
nohup java -jar simple-parcel-service-app-1.0-SNAPSHOT.jar > app.log 2>&1 &
echo "Application started"
"""
}
}
}

}
}