From a362896c5734adafbb47af00d53c34a406cbb38a Mon Sep 17 00:00:00 2001 From: Vishnu Venugopalan Date: Thu, 14 Dec 2023 15:06:26 -0500 Subject: [PATCH] Jenkins Pipeline file add --- Dockerfile | 14 ++++++++++++++ Jenkinsfile | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..edec394df --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..1ba177c77 --- /dev/null +++ b/Jenkinsfile @@ -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 .' + } + } + } + } +} \ No newline at end of file