Jenkins Pipeline file add

This commit is contained in:
Vishnu Venugopalan 2023-12-14 15:06:26 -05:00
parent 0aa3adb56f
commit a362896c57
2 changed files with 47 additions and 0 deletions

14
Dockerfile Normal file
View file

@ -0,0 +1,14 @@
# Use the official OpenJDK 8 as a base image
FROM openjdk:8-jdk-alpine
# Set the working directory inside the container
WORKDIR /app
# Copy the JAR file generated by Maven into the container
COPY target/*.jar app.jar
# Expose port 8080 for the application
EXPOSE 8080
# Command to run the application when the container starts
CMD ["java", "-jar", "app.jar"]

33
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,33 @@
pipeline {
agent any
stages {
// Stage 1: Compile
stage('Compile') {
steps {
script {
sh 'mvn compile'
}
}
}
// Stage 2: Run Tests
stage('Run Tests') {
steps {
script {
sh 'mvn test'
}
}
}
// Stage 3: Package as Docker Image
stage('Package as Docker Image') {
steps {
script {
sh 'mvn package'
sh 'docker build -t spring-petclinic .'
}
}
}
}
}