mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 04:55:50 +00:00
Update and rename jenkinsfile to Jenkinsfile
Signed-off-by: vinayasuresh <Vinaya@pionedata.com>
This commit is contained in:
parent
4d7c890483
commit
1cc41447c7
2 changed files with 45 additions and 27 deletions
45
Jenkinsfile
vendored
Normal file
45
Jenkinsfile
vendored
Normal 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
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
jenkinsfile
27
jenkinsfile
|
@ -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'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue