mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 07:45:49 +00:00
Jenkins Pipeline file add
This commit is contained in:
parent
0aa3adb56f
commit
a362896c57
2 changed files with 47 additions and 0 deletions
14
Dockerfile
Normal file
14
Dockerfile
Normal 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
33
Jenkinsfile
vendored
Normal 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 .'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue