Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6516805
Adding Jenkinsfiles
Bashsha12 Apr 28, 2025
1749c5a
Adding Jenkinsfiles
Bashsha12 Apr 28, 2025
d49c858
Adding Jenkinsfiles
Bashsha12 Apr 28, 2025
4fe909b
Adding Jenkinsfiles
Bashsha12 Apr 28, 2025
87e8140
Adding Jenkinsfiles
Bashsha12 Apr 28, 2025
f473db4
Adding one more Jekins file
Bashsha12 May 4, 2025
660c781
Adding one more Jekins file
Bashsha12 May 4, 2025
5ab7484
Adding one more Jekins file
Bashsha12 May 4, 2025
2b87efc
Adding one more Jekins file
Bashsha12 May 4, 2025
abdbf19
Adding one more Jekins file
Bashsha12 May 4, 2025
286f773
Adding one more Jekins file
Bashsha12 May 4, 2025
dfb5039
Adding one more Jekins file
Bashsha12 May 4, 2025
48efb48
Adding one more Jekins file
Bashsha12 May 4, 2025
0229e26
Adding one more Jekins file
Bashsha12 May 4, 2025
014e108
Adding one more Jekins file
Bashsha12 May 4, 2025
a2703bf
New Jenkins file with full deployment
Bashsha12 Sep 3, 2025
76f140b
New Jenkins file with full deployment
Bashsha12 Sep 3, 2025
6a7149e
New Jenkins file with full deployment
Bashsha12 Sep 3, 2025
376e023
test
Bashsha12 Sep 3, 2025
2a86c17
Update Jenkinsfile3
Bashsha12 Sep 4, 2025
4d34311
Modifing the Jenkinsfile3
Bashsha12 Sep 4, 2025
474849d
Update Jenkinsfile3
Bashsha12 Sep 8, 2025
8cfb4e5
Quality Gate Analysis
Bashsha12 Sep 9, 2025
be67bc5
Adding Build and push docker image stage
Bashsha12 Sep 9, 2025
77f5ec7
Rebasing the docker file
Bashsha12 Sep 9, 2025
f24f731
Rebasing the docker file
Bashsha12 Sep 9, 2025
ae06a19
Adding Clean Workspace stage
Bashsha12 Sep 9, 2025
7fb53fc
Enahanced Jenkins & Docker files
Bashsha12 Sep 9, 2025
79c1d16
Adding creds for dockerhub login
Bashsha12 Sep 9, 2025
bca715a
Refactoring the Build and push stage
Bashsha12 Sep 9, 2025
6204c05
Refactoring the Build and push stage
Bashsha12 Sep 9, 2025
07fe114
For Build Trigger
Bashsha12 Sep 9, 2025
bd9d927
For Build Trigger
Bashsha12 Sep 9, 2025
a991322
For Build Trigger
Bashsha12 Sep 9, 2025
4961e9e
Testing
Bashsha12 Sep 9, 2025
a1cb89f
Testing
Bashsha12 Sep 10, 2025
e004141
Testing
Bashsha12 Sep 10, 2025
e4da5db
Testing
Bashsha12 Sep 10, 2025
a383096
Parallel execution
Bashsha12 Sep 10, 2025
df94222
Parallel execution
Bashsha12 Sep 10, 2025
8569997
Parallel execution
Bashsha12 Sep 10, 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
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
FROM amazoncorretto:11-al2023-jdk⁠
WORKDIR /app
COPY target/maven-standalone-application*.jar maven-standalone-application.jar
CMD ["java","-jar","maven-standalone-application.jar"]
# ---------- Stage 1: Runtime only -------
FROM eclipse-temurin:21-jre-jammy
# Set working directory inside the container
WORKDIR /app

# The JAR will be specified dynamically via build args
ARG JAR_FILE
COPY ${JAR_FILE} app.jar

EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
36 changes: 35 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@

pipeline {
agent any
stages {
stage('Build') {
agent {
docker {
image 'maven:amazoncorretto'
reuseNode true
}
}
steps {
sh '''
echo "Cleaning maven cache and target folder..."
rm -rf target
mvn clean install
mvn package
mvn --version
echo "Hello Welcome to Jenkins"
ls -la
'''
}
}
stage('Test') {
steps {
echo "Running tests..."
sh '''
mvn test
# Ensure we're using bash
echo "Running tests..."
bash -c 'a=(1 3 4 5); echo "Array elements: ${a[@]: -2}"'
'''
}
}
}
}
44 changes: 44 additions & 0 deletions Jenkinsfile1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
pipeline{
agent any
tools{
maven "MAVEN"
jdk "JDK17"
}
stages{
stage("Fetch code from GitHub"){
steps{
echo "========fetching code from GitHub========"
git branch: 'master', url: 'https://github.com/Bashsha12/maven-standalone-application.git'
}

}
stage('Unittest'){
steps{
echo "========Running unit tests========"
sh 'mvn clean test'
}
}
stage('Build'){
steps{
echo "========Building the project========"
sh '''
mvn install -DskipTests=true
'''

echo "========Build completed========"
}
post{
success{
echo "========Build was successful========"
echo "========Archiving artifacts========"
archiveArtifacts artifacts: '**/target/*.jar'
echo "========Artifacts archived========"
}
failure{
echo "========Build failed========"
}
}

}
}
}
92 changes: 92 additions & 0 deletions Jenkinsfile2
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
pipeline {
agent any
tools {
maven "MAVEN"
jdk "JDK17"
}
stages {
stage("Fetch code from GitHub") {
steps {
echo "========fetching code from GitHub========"
git branch: 'master', url: 'https://github.com/Bashsha12/maven-standalone-application.git'
}
}
stage("Build") {
steps {
echo "========building the application========"

sh 'mvn clean install -DskipTests=true'
sh 'mvn package'
sh 'mvn clean package'
}
post {
success {
echo "========Build was successful========"
echo "========Archiving artifacts========"
archiveArtifacts artifacts: '**/target/*.jar'
echo "========Artifacts archived========"
}
failure {
echo "========Build failed========"
}
}
}
stage("Unit Test") {
steps {
echo "========Running unit tests========"
sh 'mvn test'
}
}
stage("Checkstyle") {
steps {
echo "========Running checkstyle========"
sh 'mvn checkstyle:checkstyle'
}
}
stage("SonarQube") {
environment {
scannerHome = tool 'sonar7.1'
}
steps {
echo "========Running SonarQube analysis========"
withSonarQubeEnv('sonarsever') {
sh '''
${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=maven-standalone-application \
-Dsonar.projectName=maven-standalone-application \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src/ \
-Dsonar.java.binaries=target/classes \
-Dsonar.junit.reportPaths=target/surefire-reports/ \
-Dsonar.jacoco.reportPaths=target/jacoco.exec \
-Dsonar.java.checkstyle.reportPath=target/checkstyle-result.xml \
'''
}
}
}
stage("SonarQube Quality Gate") {
steps {
timeout(time: 1, unit: 'HOURS') {
waitForQualityGate abortPipeline: true
}
}
}
stage('Upload to Nexus') {
steps {
echo "========Uploading artifacts to Nexus========"
nexusArtifactUploader artifacts: [
[artifactId: 'maven-standalone-application',
classifier: '',
file: 'target/maven-standalone-application-0.0.1-SNAPSHOT.jar', type: 'jar']
],
credentialsId: 'nexuslogin',
groupId: 'QA',
nexusUrl: '172.31.41.195:8081',
nexusVersion: 'nexus3',
protocol: 'http',
repository: 'maven-standalone-application-repo',
version: "${env.BUILD}-${env.BUILD_TIMESTAMP}"
echo "========Upload to Nexus completed========"
}
}
}
}
138 changes: 138 additions & 0 deletions Jenkinsfile3
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
def COLOR_MAP = [
'SUCCESS': 'good',
'FAILURE': 'danger',
'ABORTED': '#808080',
'UNSTABLE': 'warning'
]
pipeline{
agent {
label 'master'
}
tools {
maven 'Maven'
jdk 'Java21'
}
environment{
sonarqube_server = 'Sonar'
DOCKERHUB_CRED= 'DOCKERHUB_CRED'
DOCKER_REGISTRY= "bashadockerhubdemo"
DOCKER_IMAGE_NAME= "maven-standalone-app"
AWSRegion= "ap-south-1"
ClusterName= "my-ecs-cluster"
ServiceName= "maven-standalone-service"
}
stages{
stage("Checkout"){
steps{
git url: 'https://github.com/Bashsha12/maven-standalone-application.git'
}
}
stage("Build stage"){
steps{
sh 'mvn clean package -DskipTests=true'
stash includes: 'target/*.jar', name: 'app-jar'
}
}
stage("Testing stage"){
parallel{
stage("Unit Test"){
steps{
sh 'mvn test'
}
}
stage("Integration Test"){
steps{
sh 'mvn verify -DskipUnitTests=true'
}
}
stage("Checkstyle Report"){
steps{
sh 'mvn checkstyle:checkstyle'
}
}
}
}
stage("SonarQube Analysis"){
steps{
script {
def scannerHome = tool 'Sonar'
withSonarQubeEnv("${sonarqube_server}") {
sh """
${scannerHome}/bin/sonar-scanner \
-Dsonar.projectKey=maven-standalone-application \
-Dsonar.projectName=maven-standalone-application \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src/ \
-Dsonar.java.binaries=target/classes \
-Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml \
-Dsonar.java.coveragePlugin=jacoco \
-Dsonar.jacoco.reportPaths=target/jacoco.exec \
-Dsonar.junit.reportPaths=target/surefire-reports/
"""
}
}
}

}
stage("Quality Gate"){
steps{
script {
timeout(time: 1, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
/*
stage("Build and Push Docker Image"){
steps{
unstash 'app-jar'
script {
def imageTag = "${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${env.BUILD_NUMBER}"
def jarFile = sh(script: "ls target/*.jar | head -n 1", returnStdout: true).trim()
withCredentials([usernamePassword(credentialsId: "${DOCKERHUB_CRED}", usernameVariable: 'DOCKERHUB_USER', passwordVariable: 'DOCKERHUB_PASS')]) {
sh "docker build --cache-from --build-arg JAR_FILE=${jarFile} -t ${imageTag} ${WORKSPACE}"
sh 'echo $DOCKERHUB_PASS | docker login -u $DOCKERHUB_USER --password-stdin'
sh "docker push ${imageTag}"
}
}
}
}
stage("Deploy to AWS ECS"){
steps{
script {
sh "aws ecs update-service --cluster ${ClusterName} --service ${ServiceName} --force-new-deployment --region ${AWSRegion}"
}
}
}*/
}
post {
always {
script {
def result = currentBuild.currentResult
def emoji = ""
if (result == "SUCCESS") {
emoji = ":smile:"
} else if (result == "FAILURE") {
emoji = ":cry:"
} else if (result == "ABORTED") {
emoji = ":no_entry_sign:"
} else {
emoji = ":warning:"
}

slackSend(
channel: '#devopscicd',
color: COLOR_MAP[result],
message: "${emoji} *${result}*: Job `${env.JOB_NAME}` build #${env.BUILD_NUMBER} \nCheck console: ${env.BUILD_URL}"
)
}
}
}


}

1 change: 1 addition & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sample