Update and rename jenkinsfile to Jenkinsfile

Signed-off-by: vinayasuresh <Vinaya@pionedata.com>
This commit is contained in:
vinayasuresh 2025-06-24 12:18:14 +05:30 committed by GitHub
parent 4d7c890483
commit 1cc41447c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 27 deletions

45
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,45 @@
pipeline {
agent any
environment {
IMAGE_NAME = "local-app:latest"
CONTAINER_NAME = "local-app-container"
}
stages {
stage('Checkout') {
steps {
git 'https://github.com/vinayasuresh/spring-petclinic.git'
}
}
stage('Build App') {
steps {
sh 'mvn clean package -DskipTests'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t $IMAGE_NAME .'
}
}
stage('Stop Existing Container') {
steps {
sh '''
docker stop $CONTAINER_NAME || true
docker rm $CONTAINER_NAME || true
'''
}
}
stage('Run Docker Container') {
steps {
sh '''
docker run -d --name $CONTAINER_NAME -p 8080:8080 $IMAGE_NAME
'''
}
}
}
}

View file

@ -1,27 +0,0 @@
pipeline {
agent any
environment {
IMAGE_NAME = 'app'
}
stages {
stage('Clone') {
steps {
git 'https://github.com/vinayasuresh/spring-petclinic'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t $IMAGE_NAME .'
}
}
stage('Run Container') {
steps {
sh 'docker run -d --rm --name spring-petfield -p 3000:3000 $IMAGE_NAME'
}
}
}
}