Skip to content

Feature/my change #1930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
10a269d
Updated Project
prankumargrid Mar 19, 2025
4ce7ed9
Initial commit with Dockerfile and Jenkinsfile
prankumargrid Apr 23, 2025
8184261
Update Jenkinsfile
prankumargrid Apr 25, 2025
8c3f545
Update checkstyle.xml
prankumargrid Apr 25, 2025
cab11b2
Update Jenkinsfile
prankumargrid Apr 25, 2025
e0b343e
Update Jenkinsfile
prankumargrid Apr 25, 2025
b1861ba
Update Jenkinsfile
prankumargrid Apr 25, 2025
ab0a177
Update Jenkinsfile
prankumargrid Apr 25, 2025
0e7ad09
Update Dockerfile
prankumargrid Apr 29, 2025
8d18fa0
Update Jenkinsfile
prankumargrid Apr 29, 2025
00e590d
Update Jenkinsfile
prankumargrid Apr 29, 2025
0831c86
Update Jenkinsfile
prankumargrid Apr 29, 2025
2bb02af
Update Jenkinsfile
prankumargrid Apr 29, 2025
d85042c
Update Jenkinsfile
prankumargrid Apr 29, 2025
86268d9
Update Jenkinsfile
prankumargrid Apr 29, 2025
77c31d5
Update Jenkinsfile
prankumargrid Apr 29, 2025
03ac881
Update Jenkinsfile
prankumargrid Apr 30, 2025
8ce35be
Update Dockerfile
prankumargrid Apr 30, 2025
ea795ed
Update Jenkinsfile
prankumargrid Apr 30, 2025
9bc6c07
Update Jenkinsfile
prankumargrid May 1, 2025
9344fdd
Update Jenkinsfile
prankumargrid May 1, 2025
5aeb5e7
Update Jenkinsfile
prankumargrid May 1, 2025
fc1cf55
Update Jenkinsfile
prankumargrid May 1, 2025
af1abda
Update Jenkinsfile
prankumargrid May 1, 2025
96c8f86
Update Jenkinsfile
prankumargrid May 1, 2025
d2f5f24
Update Jenkinsfile
prankumargrid May 1, 2025
6ab5645
Update Jenkinsfile
prankumargrid May 1, 2025
5ce47b0
Added Workflow
prankumargrid Jun 16, 2025
067e66e
Added Docker workflow
prankumargrid Jun 16, 2025
87296dc
Trigger build
prankumargrid Jun 16, 2025
7d6b6fc
Add matrix build for Java versions
prankumargrid Jun 16, 2025
dda265e
Trigger build
prankumargrid Jun 16, 2025
cc53c62
Build Commit
prankumargrid Jun 16, 2025
96d3f40
Next Build Commit
prankumargrid Jun 16, 2025
94c1e60
Test Build Commit
prankumargrid Jun 16, 2025
bee5124
Update build-matrix.yaml
prankumargrid Jun 16, 2025
d046b63
Multi Job Pipeline
prankumargrid Jun 16, 2025
54f81c4
Merge branch 'main' of https://github.com/prankumargrid/spring-petclinic
prankumargrid Jun 16, 2025
147a8b4
Multistage build
prankumargrid Jun 17, 2025
f75ad7e
CI/CD Pipeline
prankumargrid Jun 18, 2025
9823bf3
Corrected Pipeline
prankumargrid Jun 18, 2025
f4dcd30
Rectified Pipeline
prankumargrid Jun 18, 2025
c9572d6
Test PR Trigger
prankumargrid Jun 18, 2025
0f242dd
Merge branch 'main' into feature/my-change
prankumargrid Jun 18, 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
94 changes: 94 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Spring PetClinic CI/CD

on:
pull_request:
branches: [main]
push:
branches: [main]

env:
IMAGE_NAME: spring-petclinic

jobs:
checkstyle:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Checkstyle
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Checkstyle
run: ./gradlew checkstyleMain checkstyleTest
- name: Upload Checkstyle Report
uses: actions/upload-artifact@v4
with:
name: checkstyle-report
path: build/reports/checkstyle/

test:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: checkstyle
name: Run Tests
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- run: ./gradlew test

build:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: test
name: Build App
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- run: ./gradlew build -x test

docker-pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: build
name: Build & Push Docker Image (MR)
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build & Push
run: |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
docker build -t ${{ secrets.DOCKER_USERNAME }}/mr:${SHORT_SHA} .
docker push ${{ secrets.DOCKER_USERNAME }}/mr:${SHORT_SHA}

docker-main:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
name: Build & Push Docker Image (Main)
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build & Push
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/main:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/main:latest

31 changes: 0 additions & 31 deletions .github/workflows/deploy-and-test-cluster.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/gradle-build.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/maven-build.yml

This file was deleted.

11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM eclipse-temurin:17-jdk as builder
WORKDIR /app
COPY . .
RUN ./gradlew build -x test

FROM eclipse-temurin:17-jre
WORKDIR /app
COPY --from=builder /app/build/libs/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
`
72 changes: 72 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
pipeline {
agent none

environment {
DOCKERHUB_USER = "prankumar313"
}

stages {
stage('Checkstyle') {
agent {
docker {
image 'gradle:8.1.1-jdk17'
}
}
when {
expression { env.BRANCH_NAME != 'main' }
}
steps {
sh './gradlew checkstyleMain checkstyleTest'
archiveArtifacts artifacts: '**/build/reports/checkstyle/*.xml', allowEmptyArchive: true
}
}

stage('Test') {
agent {
docker {
image 'gradle:8.1.1-jdk17'
}
}
when {
expression { env.BRANCH_NAME != 'main' }
}
steps {
sh './gradlew test'
}
}

stage('Build (No Tests)') {
agent {
docker {
image 'gradle:8.1.1-jdk17'
}
}
when {
expression { env.BRANCH_NAME != 'main' }
}
steps {
sh './gradlew build -x test'
}
}

stage('Build & Push Docker Image') {
agent { label 'docker-enabled' } // runs on a node with Docker installed
steps {
script {
def commit = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
def repo = env.BRANCH_NAME == 'main' ? 'main' : 'mr'
def image = "${DOCKERHUB_USER}/${repo}:${commit}"

sh "docker build -t ${image} ."

withCredentials([usernamePassword(credentialsId: 'dockerhub-creds', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
sh """
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
docker push ${image}
"""
}
}
}
}
}
}
23 changes: 18 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.0'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.graalvm.buildtools.native' version '0.10.6'
id 'org.cyclonedx.bom' version '2.3.1'
id 'io.spring.javaformat' version '0.0.46'
id 'checkstyle'
id 'org.springframework.boot' version '3.4.2'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.graalvm.buildtools.native' version '0.10.3'
id 'org.cyclonedx.bom' version '1.10.0'
id 'io.spring.javaformat' version '0.0.43'
id "io.spring.nohttp" version "0.0.11"
id 'pl.allegro.tech.build.axion-release' version '1.18.18'
}

version=scmVersion.version

apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'io.spring.javaformat'
Expand All @@ -21,6 +25,14 @@ java {
sourceCompatibility = JavaVersion.VERSION_17
}

checkstyle{
toolVersion = '10.12.3'
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
configProperties = [
'checkstyle.cache.file': "${buildDir}/checkstyle/cachefile"
]
}

repositories {
mavenCentral()
}
Expand Down Expand Up @@ -85,3 +97,4 @@ checkFormatAotTest.enabled = false

formatAot.enabled = false
formatAotTest.enabled = false

Loading