Create Jenkinsfile

Signed-off-by: eswarsai097 <90921994+eswarsai097@users.noreply.github.com>
This commit is contained in:
eswarsai097 2025-05-19 23:47:07 -05:00 committed by GitHub
parent 3a931080d4
commit 19b6ef7608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

58
src/Jenkinsfile vendored Normal file
View file

@ -0,0 +1,58 @@
pipeline {
agent any
environment {
DOCKER_IMAGE = "yourdockerhubusername/petclinic"
DOCKER_CREDENTIALS_ID = "dockerhub-creds"
}
stages {
stage('Checkout') {
steps {
git 'https://github.com/spring-projects/spring-petclinic.git'
}
}
stage('Build') {
steps {
sh './mvnw clean install'
}
}
stage('Test') {
steps {
sh './mvnw test'
}
}
stage('Docker Build & Push') {
steps {
script {
docker.withRegistry('', DOCKER_CREDENTIALS_ID) {
def app = docker.build("${DOCKER_IMAGE}:latest")
app.push()
}
}
}
}
stage('Deploy (Simulated)') {
steps {
echo "Deploying ${DOCKER_IMAGE}:latest to staging environment..."
// You can replace with kubectl apply -f deployment.yaml or Helm
}
}
}
post {
always {
echo 'Pipeline finished.'
}
success {
echo 'CI/CD pipeline completed successfully.'
}
failure {
echo 'CI/CD pipeline failed!'
}
}
}