Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
4149126
adding feature-1
vikas0105 Dec 22, 2023
6195045
adding feature -2 files
vikas0105 Dec 22, 2023
c067629
Create README.md
vikas0105 Dec 24, 2024
91e37e9
Update README.md
vikas0105 Dec 24, 2024
b35daca
test
vikas0105 Dec 24, 2024
9a1385a
Merge branch 'feature-1' of https://github.com/vikas0105/Parcel-servi…
vikas0105 Dec 24, 2024
9485255
test
vikas0105 Dec 24, 2024
124bcdc
test
vikas0105 Dec 24, 2024
6e52445
test
vikas0105 Dec 24, 2024
bdf5f54
test
vikas0105 Dec 24, 2024
8585b3f
Update README.md
vikas0105 Dec 24, 2024
2e320f9
Update README.md
vikas0105 Dec 24, 2024
c3b13a8
Update Build.yml
vikas0105 Jan 2, 2025
a1ac454
test
vikas0105 Jan 2, 2025
589ee16
test
vikas0105 Jan 2, 2025
a9be0ab
test
vikas0105 Jan 2, 2025
6b0f530
test
vikas0105 Jan 2, 2025
f12423e
test
vikas0105 Jan 2, 2025
492a56f
test
vikas0105 Jan 2, 2025
694897a
test
vikas0105 Jan 2, 2025
205dff3
test
vikas0105 Jan 2, 2025
a7e07cb
test
vikas0105 Jan 2, 2025
a8b4fc8
test
vikas0105 Jan 2, 2025
36b4542
test
vikas0105 Jan 2, 2025
8269ecf
test
vikas0105 Jan 2, 2025
250e4db
test
vikas0105 Jan 2, 2025
0436bb4
test
vikas0105 Jan 2, 2025
50f985a
test
vikas0105 Jan 2, 2025
f4384f8
test
vikas0105 Jan 2, 2025
c6cc021
test
vikas0105 Jan 2, 2025
8f91197
test
vikas0105 Jan 2, 2025
d09295b
test
vikas0105 Jan 2, 2025
a7d5742
test
vikas0105 Jan 2, 2025
b01fb92
test
vikas0105 Jan 2, 2025
df5c472
test
vikas0105 Jan 2, 2025
b3199b3
test
vikas0105 Jan 2, 2025
31ec73c
test
vikas0105 Jan 2, 2025
4b4b752
test
vikas0105 Jan 2, 2025
dd70ba4
test
vikas0105 Jan 2, 2025
5859a71
test
vikas0105 Jan 2, 2025
93544f8
test
vikas0105 Jan 2, 2025
18634ea
test
vikas0105 Jan 2, 2025
0bb4983
test
vikas0105 Jan 2, 2025
2e306a4
test
vikas0105 Jan 2, 2025
272ead3
test
vikas0105 Jan 2, 2025
8044566
test
vikas0105 Jan 2, 2025
4a76fff
test
vikas0105 Jan 2, 2025
8077b7f
test
vikas0105 Jan 2, 2025
249aac8
test
vikas0105 Jan 2, 2025
84ccb0b
test
vikas0105 Jan 2, 2025
f8d8955
test
vikas0105 Jan 2, 2025
d824391
test
vikas0105 Jan 2, 2025
f2bba9c
test
vikas0105 Jan 2, 2025
6e9f4cf
test
vikas0105 Jan 2, 2025
736e8e6
test
vikas0105 Jan 2, 2025
b51bb64
test
vikas0105 Jan 2, 2025
bd96c86
test
vikas0105 Jan 2, 2025
95c2878
test
vikas0105 Jan 2, 2025
e7ab4c2
test
vikas0105 Jan 2, 2025
2f2f3da
test
vikas0105 Jan 2, 2025
aeb3fd4
test
vikas0105 Jan 2, 2025
fb1ccd1
test
vikas0105 Jan 2, 2025
5eeb54f
test
vikas0105 Jan 2, 2025
0d59957
test
vikas0105 Jan 2, 2025
8839044
test
vikas0105 Jan 2, 2025
5862585
test
vikas0105 Jan 2, 2025
0c19871
test
vikas0105 Jan 2, 2025
968339e
test
vikas0105 Jan 2, 2025
fa1b9cd
test
vikas0105 Jan 2, 2025
c069c99
test
vikas0105 Jan 2, 2025
5e5bb48
test
vikas0105 Jan 2, 2025
73ea3ca
test
vikas0105 Jan 2, 2025
bcb0219
test
vikas0105 Jan 2, 2025
ab208f0
test
vikas0105 Jan 2, 2025
87555e8
test
vikas0105 Jan 2, 2025
a86bda7
test
vikas0105 Jan 2, 2025
e31e212
test
vikas0105 Jan 2, 2025
38a5b35
test
vikas0105 Jan 2, 2025
baddbed
test
vikas0105 Jan 2, 2025
aab8aa7
test
vikas0105 Jan 2, 2025
fb22439
test
vikas0105 Jan 2, 2025
74ffb0a
test
vikas0105 Jan 2, 2025
f10566e
test
vikas0105 Jan 2, 2025
103dc24
test
vikas0105 Jan 2, 2025
fae2241
test
vikas0105 Jan 2, 2025
5c8b3cc
test
vikas0105 Jan 2, 2025
7ae80ab
test
vikas0105 Jan 2, 2025
a8242a7
test
vikas0105 Jan 2, 2025
61dcfe6
test
vikas0105 Jan 3, 2025
37d6556
test
vikas0105 Jan 3, 2025
e3789a9
Update Build.yml
vikas0105 Jan 20, 2025
4bf8606
Update Build.yml
vikas0105 Jan 20, 2025
2f433ef
Update Build.yml
vikas0105 Jan 20, 2025
5e8b317
Update Build.yml
vikas0105 Jan 20, 2025
3277314
Update Build.yml
vikas0105 Jan 20, 2025
5fe3eea
Update Build.yml
vikas0105 Jan 20, 2025
5b8da85
Update Build.yml
vikas0105 Jan 20, 2025
8603ef3
Update Build.yml
vikas0105 Jan 20, 2025
da01f5c
Update Build.yml
vikas0105 Jan 20, 2025
c632557
Update Build.yml
vikas0105 Jan 20, 2025
d5f2536
Update Build.yml
vikas0105 Jan 20, 2025
f89f279
Update Build.yml
vikas0105 Jan 20, 2025
be8ba76
Update Build.yml
vikas0105 Jan 20, 2025
b3e0309
Update build.yml
vikas0105 Jan 20, 2025
7846da7
Rename Build.yml to main.yml
vikas0105 Jan 20, 2025
ceaf502
adding templates
Jan 20, 2025
47070cc
adding templates
Jan 20, 2025
2560df2
adding templates
Jan 20, 2025
7dc7c23
adding templates
Jan 20, 2025
e2ed1a3
adding templates
Jan 20, 2025
ad3bce4
adding templates
Jan 20, 2025
48997ba
adding templates
Jan 20, 2025
97ed8af
adding templates
Jan 20, 2025
7a2ce94
adding templates
Jan 20, 2025
beae017
adding templates
Jan 20, 2025
5feed07
adding templates
Jan 20, 2025
071951b
adding templates
Jan 20, 2025
d0244c0
adding templates
Jan 20, 2025
653a65a
adding templates
Jan 20, 2025
0c52252
adding templates
Jan 20, 2025
fa3fcf9
adding templates
Jan 20, 2025
70b7682
adding templates
Jan 20, 2025
afa01a6
adding templates
Jan 20, 2025
c343f07
adding templates
Jan 20, 2025
3726a5d
adding templates
Jan 20, 2025
7c90bd5
Update main.yml
vikas0105 Jan 21, 2025
41386f3
Update main.yml
vikas0105 Jan 22, 2025
c6442cf
feature-1 run
Jan 22, 2025
f9a66a5
Update Jenkinsfile
vikas0105 Dec 2, 2025
81d88ef
Update README.md
vikas0105 Dec 2, 2025
dcb8251
Update installation message for Java version
vikas0105 Dec 2, 2025
bae2a4d
Update README to remove repository cloning steps
vikas0105 Dec 2, 2025
3931175
Update README.md
vikas0105 Dec 2, 2025
b24dd4b
Update Jenkinsfile
manij-20 Dec 4, 2025
88fb65e
Create Jenkinsfile
manij-20 Dec 4, 2025
ec2216d
Merge branch 'feature-1' into main
manij-20 Dec 4, 2025
03b5c26
Update Jenkinsfile
manij-20 Dec 4, 2025
5ad336a
Merge branch 'feature-2' into main
manij-20 Dec 4, 2025
ffb014b
Update Jenkinsfile
manij-20 Dec 4, 2025
6a50d60
Update Jenkinsfile
manij-20 Dec 4, 2025
ba110fd
Update Jenkinsfile
manij-20 Dec 8, 2025
0e64d9a
Update Jenkinsfile
manij-20 Dec 8, 2025
1bce923
Update Jenkinsfile
manij-20 Dec 8, 2025
f9b2d4f
Delete .github/workflows/build-and-artifact.yml
manij-20 Dec 12, 2025
ec16d83
Delete .github/workflows/setup-java-maven.yml
manij-20 Dec 12, 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
128 changes: 128 additions & 0 deletions .github/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Build, Deploy, and Analyze

on:
push:
branches:
- '**'
pull_request:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: self-hosted

steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3

# Install Maven
- name: Install Maven
run: |
sudo apt update
sudo apt install maven -y
mvn -v

# Set up Java
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

# Cache Maven dependencies
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

# Build the project with Maven
- name: Build with Maven
run: mvn clean install

# Store artifacts with versioning (Before running the .jar)
- name: Upload Artifacts with Versioning
uses: actions/upload-artifact@v3
with:
name: my-app-artifact-${{ github.sha }} # Artifact version based on commit SHA
path: target/*.jar # Path to the built artifact (e.g., JAR file or other build outputs)

# Run the Spring Boot application in the background
- name: Run Spring Boot App
run: mvn spring-boot:run &

# Wait for the Spring Boot app to fully start
- name: Wait for Spring Boot App to Start
run: |
echo "Waiting for the app to start..."
sleep 15 # Allow time for the Spring Boot app to fully initialize
echo "App should now be running."

# Validate that the application is running
- name: Validate App is Running
run: |
echo "Checking if the app is running..."
IP_ADDRESS=$(curl -s ifconfig.me) # Fetch public IP address
PORT=8080
RESPONSE=$(curl --write-out "%{http_code}" --silent --output /dev/null http://$IP_ADDRESS:$PORT)
if [ "$RESPONSE" -eq 200 ]; then
echo "The app is running successfully at http://$IP_ADDRESS:$PORT!"
else
echo "The app failed to start. HTTP response code: $RESPONSE"
exit 1
fi

# Display the IP address and port number for accessing the app
- name: Display IP Address and Port
run: |
echo "Fetching the runner's IP address..."
IP_ADDRESS=$(curl -s ifconfig.me) # This fetches the public IP of the runner
PORT=8080
echo "The app is accessible at: http://$IP_ADDRESS:$PORT"

# Wait for 3 minutes (180 seconds)
- name: Wait for 3 minutes
run: |
echo "App has been running for 3 minutes. Waiting..."
sleep 180 # Wait for 3 minutes

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

sonarcloud-analysis:
runs-on: ubuntu-latest
needs: build # Ensure the build job runs before sonarcloud-analysis job

steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3

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

# SonarCloud Analysis (separate job-feature-1)
- name: SonarCloud Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_ORG: your-organization # Replace with your actual SonarCloud organization
SONAR_HOST_URL: https://sonarcloud.io
run: |
mvn clean verify sonar:sonar \
-Dsonar.organization=${{ secrets.SONAR_ORG }} \
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
Comment on lines +101 to +127
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find and read the GitHub workflow file
find . -name "main.yml" -path "*/.github/*" | head -5

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# List files in .github directory
find .github -type f 2>/dev/null | head -20

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# Check if .github directory exists and list root structure
ls -la | head -20

Repository: vikas0105/Parcel-service

Length of output: 436


🏁 Script executed:

# Search for any workflow files
find . -name "*.yml" -o -name "*.yaml" 2>/dev/null | grep -v ".git"

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# Check git history to see if the file ever existed
git log --all --full-history -- ".github/main.yml" | head -20

Repository: vikas0105/Parcel-service

Length of output: 625


🏁 Script executed:

# Check current branch and HEAD
git branch -v
git show HEAD:.github/main.yml 2>/dev/null | head -150

Repository: vikas0105/Parcel-service

Length of output: 240


🏁 Script executed:

# Get the file from the commit that updated it
git show 41386f37cc56dbf01348db5c04b5cc63be79de94:.github/main.yml 2>/dev/null | cat -n | sed -n '101,127p'

Repository: vikas0105/Parcel-service

Length of output: 1168


🏁 Script executed:

# Get the full workflow file from the same commit
git show 41386f37cc56dbf01348db5c04b5cc63be79de94:.github/main.yml 2>/dev/null | cat -n | head -100

Repository: vikas0105/Parcel-service

Length of output: 3927


Fix SonarCloud env var wiring: use env vars instead of secrets for non-sensitive values.

The SONAR_ORG and SONAR_HOST_URL are defined in the env block but the Maven command references them via ${{ secrets.SONAR_ORG }} and ${{ secrets.SONAR_HOST_URL }}. Unless those are also created as secrets, these will be empty. Use:

       - name: SonarCloud Analysis
         env:
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
           SONAR_ORG: your-organization # Replace with your actual SonarCloud organization
           SONAR_HOST_URL: https://sonarcloud.io
         run: |
           mvn clean verify sonar:sonar \
-            -Dsonar.organization=${{ secrets.SONAR_ORG }} \
-            -Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
+            -Dsonar.organization=$SONAR_ORG \
+            -Dsonar.host.url=$SONAR_HOST_URL \
             -Dsonar.login=${{ secrets.SONAR_TOKEN }}

Also note: the build job runs mvn clean install and the sonarcloud-analysis job runs mvn clean verify sonar:sonar. Both include test execution, so tests run twice. If build time becomes an issue, consider reusing coverage data from the build job instead of rebuilding.

🤖 Prompt for AI Agents
In .github/main.yml around lines 101 to 127, the SonarCloud job references
SONAR_ORG and SONAR_HOST_URL via secrets but they are set in the env block;
update the Maven command to use the env variables (e.g. ${ENV_VAR} or
$SONAR_ORG/$SONAR_HOST_URL depending on shell context) instead of secrets so the
values are actually passed, and remove or correct the secrets.* references;
additionally, to avoid running tests twice, change the build/sonar invocation to
stop re-running tests (e.g. reuse artifacts/coverage from the build job or run
sonar:sonar without a full rebuild/test) — implement one of these approaches
consistently and ensure env wiring and test-reuse are reflected in the workflow.


35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build, Deploy, and Analyze

on:
push:
branches:
- '**'
pull_request:
branches:
- master
workflow_dispatch: # Allow for manual trigger via GitHub UI

jobs:
# Call the Java and Maven setup workflow
java-maven-setup:
uses: ./.github/workflows/setup-java-maven.yml # Reference to the consolidated Java and Maven setup workflow

# Call the build and artifact workflow
build-and-artifact:
uses: ./.github/workflows/build-and-artifact.yml # Reference to the build workflow
needs: java-maven-setup # Ensure Java and Maven setup is completed first

# Call the Spring Boot run and stop workflow
springboot-run-stop:
uses: ./.github/workflows/springboot-run-stop.yml # Reference to the Spring Boot workflow
needs: build-and-artifact # Ensure the build is completed before running Spring Boot

# Call the SonarCloud analysis workflow
sonarcloud-analysis:
uses: ./.github/workflows/sonarcloud-analysis.yml # Reference to the SonarCloud analysis workflow
needs: build-and-artifact # Ensure the build job is completed before analysis
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_ORG: ${{ secrets.SONAR_ORG }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

39 changes: 39 additions & 0 deletions .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: SonarCloud Analysis

on:
workflow_call:
secrets:
SONAR_TOKEN: # SonarCloud authentication token
required: true
SONAR_ORG: # SonarCloud organization
required: true
SONAR_HOST_URL: # SonarCloud host URL
required: true

jobs:
sonarcloud-analysis:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3

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

# Perform SonarCloud Analysis
- name: SonarCloud Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_ORG: ${{ secrets.SONAR_ORG }}
SONAR_HOST_URL: https://sonarcloud.io
run: |
mvn clean verify sonar:sonar \
-Dsonar.organization=${{ secrets.SONAR_ORG }} \
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/springboot-run-stop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Spring Boot Run and Stop

on:
workflow_call: # This workflow can be called from other workflows

jobs:
springboot-run-stop:
runs-on: self-hosted

steps:
# Run Spring Boot App
- name: Run Spring Boot App
run: mvn spring-boot:run &

# Wait for the Spring Boot app to fully start
- name: Wait for Spring Boot App to Start
run: |
echo "Waiting for the app to start..."
sleep 15
echo "App should now be running."

# Validate that the application is running
- name: Validate App is Running
run: |
echo "Checking if the app is running..."
IP_ADDRESS=$(curl -s ifconfig.me) # Fetch public IP address
PORT=8080
RESPONSE=$(curl --write-out "%{http_code}" --silent --output /dev/null http://$IP_ADDRESS:$PORT)
if [ "$RESPONSE" -eq 200 ]; then
echo "The app is running successfully at http://$IP_ADDRESS:$PORT"
else
echo "The app failed to start. HTTP response code: $RESPONSE"
exit 1
fi

# Wait for 3 minutes (180 seconds)
- name: Wait for 3 minutes
run: |
echo "App has been running for 3 minutes. Waiting..."
sleep 180

# Gracefully Stop Spring Boot App
- name: Gracefully Stop Spring Boot App
run: |
echo "Stopping the app gracefully..."
mvn spring-boot:stop
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.compile.nullAnalysis.mode": "disabled",
"java.configuration.updateBuildConfiguration": "disabled"
}
48 changes: 48 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@Library('Jenkins_library') _

pipeline {
agent { label 'java' }
// agent any
tools {
jdk 'JDK17'
maven 'maven'
}

stages {

stage('Checkout') {
steps {
checkout scm
}
}

stage('Build') {
steps {
//sh 'mvn clean package -DskipTests=false'
script {
// dir('hello-world-war') {
build 'package'
}
Comment on lines +22 to +25
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, explore the repository structure to locate the Jenkins shared library
find . -type f -name "*.groovy" | head -20

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# Search for the Jenkins_library or shared library references
find . -type d -name "vars" -o -type d -name "shared" -o -type d -name "library" | head -20

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# Look for the Jenkinsfile location and examine it
find . -name "Jenkinsfile" -type f

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

git ls-files | head -50

Repository: vikas0105/Parcel-service

Length of output: 77


🏁 Script executed:

# Check if there are any pipeline or Jenkins-related files
git ls-files | grep -i jenkins

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# Look for any groovy files
git ls-files | grep -i groovy

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# List the top-level structure
ls -la

Repository: vikas0105/Parcel-service

Length of output: 287


🏁 Script executed:

# Check all branches for Jenkinsfile
git branch -a

Repository: vikas0105/Parcel-service

Length of output: 180


🏁 Script executed:

# Search git history for any Jenkinsfile reference
git log --all --pretty=format: --name-only | grep -i jenkinsfile | sort -u

Repository: vikas0105/Parcel-service

Length of output: 109


🏁 Script executed:

# Check git log to see commits
git log --oneline --all | head -20

Repository: vikas0105/Parcel-service

Length of output: 676


🏁 Script executed:

git checkout main
git ls-files | grep -i jenkinsfile

Repository: vikas0105/Parcel-service

Length of output: 156


🏁 Script executed:

# Now read the Jenkinsfile
cat Jenkinsfile

Repository: vikas0105/Parcel-service

Length of output: 111


🏁 Script executed:

git checkout coderabbit_6
git ls-files | grep -i jenkinsfile

Repository: vikas0105/Parcel-service

Length of output: 130


🏁 Script executed:

# List all files in this branch
git ls-files

Repository: vikas0105/Parcel-service

Length of output: 958


🏁 Script executed:

cat -n Jenkinsfile

Repository: vikas0105/Parcel-service

Length of output: 1549


🏁 Script executed:

# Check if there's a shared library defined locally
find . -name "vars" -o -name "*library*" -type d

Repository: vikas0105/Parcel-service

Length of output: 50


🏁 Script executed:

# Search for Jenkins_library references or @Library annotations
grep -r "Jenkins_library\|@Library" .

Repository: vikas0105/Parcel-service

Length of output: 111


🏁 Script executed:

# Search for any documentation or comments about the Jenkins_library
grep -r "Jenkins_library" .

Repository: vikas0105/Parcel-service

Length of output: 111


🏁 Script executed:

# Check README for any Jenkins/library documentation
cat README.md

Repository: vikas0105/Parcel-service

Length of output: 3243


🏁 Script executed:

# Check pom.xml to understand Maven goals and test configuration
cat pom.xml | head -50

Repository: vikas0105/Parcel-service

Length of output: 1975


Replace the opaque custom build 'package' function with explicit Maven invocation or add documentation.

Line 24 invokes build 'package' from the Jenkins_library shared library, which obscures the actual build behavior. The commented-out code on line 21 (mvn clean package -DskipTests=false) shows tests were explicitly executed, but the custom function's test handling is unclear. Additionally, line 38 uses direct sh 'mvn spring-boot:run' invocation, creating inconsistency in how Maven is called.

Either replace with direct Maven invocation (preserving test execution):

-               script {
-                   // dir('hello-world-war') {
-                    build 'package'
-                }
+               sh 'mvn clean package -DskipTests=false'

Or document the shared library function's contract (Maven goals, test behavior, failure handling).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
script {
// dir('hello-world-war') {
build 'package'
}
sh 'mvn clean package -DskipTests=false'

}
}
Comment on lines +19 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add error handling and validation between stages.

There is no validation that the Build stage succeeded before proceeding to the Run Application stage. If the Maven build fails, the pipeline should halt immediately rather than attempting to run a non-existent or broken application.

Add explicit error handling or rely on Jenkins' native set -e behavior by using sh scripts (already default). Ensure that if Maven exits with a non-zero status, the entire pipeline fails:

         stage('Build') {
             steps {
-                //sh 'mvn clean package -DskipTests=false'
-               script {
-                   // dir('hello-world-war') {
-                    build 'package'
-                }
+               sh 'mvn clean package'
             }

This makes Maven failures immediately halt the pipeline.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
stage('Build') {
steps {
//sh 'mvn clean package -DskipTests=false'
script {
// dir('hello-world-war') {
build 'package'
}
}
}
stage('Build') {
steps {
sh 'mvn clean package'
}
}
🤖 Prompt for AI Agents
Jenkinsfile around lines 19-27: the Build stage currently calls build 'package'
with no validation and can allow the pipeline to continue if the build fails;
replace that with an explicit shell Maven invocation (e.g., sh 'mvn clean
package -DskipTests=false') so Jenkins will fail the stage on non‑zero exit, or
if you need custom handling run sh with returnStatus and explicitly error out
(throw or error step) when the status is non‑zero; ensure no downstream stages
run by failing the pipeline immediately when the Maven build fails.

// }

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: mvn spring-boot:run will block the pipeline indefinitely.

The mvn spring-boot:run command starts an embedded Tomcat server that runs indefinitely, preventing the Jenkins build from completing. This will cause the pipeline to hang and timeout.

Replace this with one of the following approaches:

Option 1: Run application in background (for smoke tests/validation):

-                sh 'mvn spring-boot:run'
+                sh '''
+                  nohup mvn spring-boot:run > app.log 2>&1 &
+                  sleep 5
+                  if ! curl -f http://localhost:8080/health; then
+                    echo "Application failed to start"
+                    exit 1
+                  fi
+                '''

Option 2: Remove this stage (recommended for typical CI/CD builds):
If the goal is only to build and package the application (not run it), delete this entire stage. The packaged JAR will be available in target/ for deployment pipelines.

-        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"
-                  // """
-              //  }
-            }
-        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sh 'mvn spring-boot:run'
sh '''
nohup mvn spring-boot:run > app.log 2>&1 &
sleep 5
if ! curl -f http://localhost:8080/health; then
echo "Application failed to start"
exit 1
fi
'''
🤖 Prompt for AI Agents
In Jenkinsfile around line 38, the pipeline currently runs "mvn spring-boot:run"
which starts the app and blocks the job indefinitely; either replace this step
with a non-blocking approach (run the JVM process in the background for
transient smoke tests, e.g., start the app in background, run tests against it,
then kill the process) or remove the stage entirely if you only need to
build/package in CI (leave mvn package or mvn verify instead so the JAR is
produced in target/ and the pipeline completes).

// 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"
// """
// }
}
}
}
}
Loading