diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..16a20e6fd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM openjdk:17-jdk-slim +WORKDIR /app +COPY target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java","-jar","app.jar"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..91c854f17 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,47 @@ +pipeline { + agent any + + stages { + + stage('Checkout') { + steps { + git 'https://github.com/spring-projects/spring-petclinic.git' + } + } + + stage('Build') { + steps { + sh 'mvn clean package -DskipTests' + } + } + + stage('Test') { + steps { + sh 'mvn test' + } + } + + stage('SonarQube Analysis') { + steps { + withSonarQubeEnv('sonarqube') { + sh 'mvn sonar:sonar' + } + } + } + + stage('Docker Build') { + steps { + sh 'docker build -t petclinic:1.0 .' + } + } + + stage('Run Application') { + steps { + sh ''' + docker rm -f petclinic || true + docker run -d -p 8081:8080 --name petclinic petclinic:1.0 + ''' + } + } + } +}