mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 13:25:49 +00:00
Create Jenkinsfile
Signed-off-by: eswarsai097 <90921994+eswarsai097@users.noreply.github.com>
This commit is contained in:
parent
3a931080d4
commit
19b6ef7608
1 changed files with 58 additions and 0 deletions
58
src/Jenkinsfile
vendored
Normal file
58
src/Jenkinsfile
vendored
Normal 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!'
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue