diff --git a/.gitignore b/.gitignore index 3deb36623..505977d3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .gradle -/build/ +#/build/ !gradle/wrapper/gradle-wrapper.jar *.db @@ -19,7 +19,7 @@ ### NetBeans ### nbproject/private/ -build/ +#build/ nbbuild/ dist/ nbdist/ diff --git a/Dockerfile b/Dockerfile index 7c7a276ec..f282c7097 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,4 @@ -FROM gradle:jdk-alpine - -WORKDIR /home/gradle/project - -EXPOSE 8080 - -USER root - -RUN apk update - -ENV GRADLE_USER_HOME /home/gradle/project - -COPY . /home/gradle/project - -RUN ./gradlew build - - FROM java:jre-alpine - WORKDIR /home/gradle/project - -COPY --from=0 /home/gradle/project/build/libs/project-0.0.1-SNAPSHOT.jar . - -ENTRYPOINT java -jar project-0.0.1-SNAPSHOT.jar +COPY build/libs/*.jar . +ENTRYPOINT java -jar project-0.0.1-SNAPSHOT.jarcommit diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..c8f66e34b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,61 @@ +pipeline{ + environment { + registry = "bharathi15/https://hub.docker.com/repositories" + registryCredential = 'Bharathi_Docker_ID' + } + agent any + stages{ + stage("sc checkout"){ + steps{ + script{ + git branch: "qa", url: "https://github.com/bharu459/spring-boot-realworld-example-app.git" + } + } + } + stage("build analysis"){ + steps{ + script{ + sh " ./gradlew build " + } + } + } + stage("source code analysis"){ + steps{ + script{ + sh " /home/cloud_user/sonar/bin/sonar-scanner " + + } + } + } + stage("build image"){ + steps{ + script{ + sh " sudo docker build -t bharathi15/spring-boot-image:latest ." + } + } + } + stage("push image to docker registry"){ + steps{ + script{ + withCredentials([string(credentialsId: 'bharathi15', variable: 'Dockerhubpwd')]) { + sh """ sudo docker login -u bharathi15 -p ${Dockerhubpwd} + sudo docker tag bharathi15/spring-boot-image:latest bharathi15/spring-boot-image:${BUILD_NUMBER} + sudo docker push bharathi15/spring-boot-image:${BUILD_NUMBER} """ + + } + } + } + } + stage("push artifact to JFROG repository"){ + steps{ + script{ + withCredentials([string(credentialsId: 'Jenkins_artifactory', variable: 'Artifactory_ID')]) { + + sh """ curl -H "X-JFrog-Art-Api:AKCp8k93MErqCS561VGxQP3ydJsrikm5oeysb5BVzgqcHidVHHva2kqDU7qRkf3EbqLrX7CLj" -T /home/cloud_user/new/spring-boot-realworld-example-app/build/libs/spring-boot-realworld-example-app-0.0.1-SNAPSHOT.jar http://c653ea429b1c.mylabserver.com:8081/artifactory/example-repo-local/spring-boot-realworld-example-app-0.0.1-SNAPSHOT:${BUILD_NUMBER}.jar """ + } + + } + } + } + } +} \ No newline at end of file diff --git a/deploy/k8s/app-service.yaml b/deploy/k8s/app-service.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/deploy/k8s/db-service.yaml b/deploy/k8s/db-service.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/deploy/k8s/deploy-app.yaml b/deploy/k8s/deploy-app.yaml new file mode 100644 index 000000000..5ef00a977 --- /dev/null +++ b/deploy/k8s/deploy-app.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: spring-boot-Deployment-file + labels: + name: spring-boot-app-deploy + app: spring-boot-Deployment +spec: + template: + metadata: + name: spring-boot-app-pod + labels: + name: spring-boot-app-pod + app: spring-boot-app + spec: + containers: + - name: spring-boot + image: bharathi15/spring-boot-image + ports: + - containerPort: 5432 + replicas: 1 + selector: + matchLabels: + name: spring-boot-app-pod + app: spring-boot-app diff --git a/deploy/k8s/deploy-db.yaml b/deploy/k8s/deploy-db.yaml new file mode 100644 index 000000000..8d7328589 --- /dev/null +++ b/deploy/k8s/deploy-db.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: redis-deploy + labels: + name: redis-deploy + app: spring-boot-app +spec: + template: + metadata: + name: redis-pod + labels: + name: redis-pod + app: spring-boot-app + spec: + containers: + - name: redis + image: redis:latest + ports: + - containerPort: 6379 + replicas: 1 + selector: + matchLabels: + name: redis-pod + app: spring-boot-app diff --git a/deploy/playbooks/deploy-app.yaml b/deploy/playbooks/deploy-app.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..671e2fcde --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,14 @@ +d37d66acd3cd88493787e76d03ebc030ddb3d04e# must be unique in a given SonarQube instance +sonar.projectKey=spring_real-world-appfrom_secondpipeline +# --- optional properties --- +# defaults to project key +sonar.projectName=spring_real-world-appfrom_secondpipeline +# defaults to 'not provided' +sonar.projectVersion=1.0 +# Path is relative to the sonar-project.properties file. Defaults to . +sonar.sources=. +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 +#sonar.host.url=http://c653ea429b1c.mylabserver.com:8066 +sonar.java.binaries=./build/libs +#sonar.login=d894764e5c4183f535fba6a4becea6a7201a3805