diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..100ffaa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# Use the latest OpenJDK image as the base image +#FROM openjdk:latest +FROM eclipse-temurin:17-jre + +# Create a directory in the Docker image to store the JAR file +WORKDIR /app + +# Copy the JAR file from the host machine to the Docker image +COPY jenkins-test-1.0.jar /app/jenkins-test-1.0.jar + +# Set the working directory +#WORKDIR /app + +# Define the command to run the Java application when the container starts +ENTRYPOINT ["java", "-jar", "/app/jenkins-test-1.0.jar"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..47852c0 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,22 @@ +pipeline{ + agent {label 'sonar'} + stages{ + /*stage('Git Checkout Stage'){ + steps{ + git branch: 'main', url: 'https://github.com/tranju664/Sonar-Qube-war-example.git' + } + }*/ + stage('Build Stage'){ + steps{ + sh 'mvn clean install' + } + } + stage('SonarQube Analysis Stage') { + steps{ + withSonarQubeEnv('sonardemo') { + sh "mvn clean verify sonar:sonar -Dsonar.projectKey=sonardemo" + } + } + } + } +} diff --git a/pom.xml b/pom.xml index 1a1862c..e4f7099 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.example jenkins-test - 1.0 + 4.0-SNAPSHOT jenkins-test Demo for jenkins diff --git a/readme b/readme index 5f78d2c..87e9954 100644 --- a/readme +++ b/readme @@ -1,3 +1,3 @@ -Java code for sprint boot application -Test -adding \ No newline at end of file +Welcome to ss training + + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 573c516..25e6b88 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,2 @@ spring.application.name=jenkins-test -server.port=8081 +server.port=8082