diff --git a/Jenkinsfile b/Jenkinsfile index a03a124..98c4712 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,25 +1,26 @@ pipeline { agent any stages { - stage('SCM Checkout'){ + stage('SCM Checkout') { steps { - git branch: 'main', url: 'https://github.com/naresh26git/microservices.git' - sh 'ls' + git branch: 'main', url: 'https://github.com/rageshtamizharasu/microservices.git' + sh 'ls' } } + stage('SonarQube Analysis') { steps { parallel ( - 'node application': { + 'nodejs application': { script { dir('cart-microservice-nodejs') { def scannerHome = tool 'sonarscanner4' - withSonarQubeEnv('sonar-pro') { - sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=cart-nodejs" - } + withSonarQubeEnv('sonar-pro') { + sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=cart-nodejs" + } } dir('ui-web-app-reactjs') { - def scannerHome = tool 'sonarscanner4'; + def scannerHome = tool 'sonarscanner4' withSonarQubeEnv('sonar-pro') { sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=ui-reactjs" } @@ -29,19 +30,19 @@ pipeline { 'spring boot application': { script { dir('offers-microservice-spring-boot') { - def mvn = tool 'maven3'; + def mvn = tool 'maven3' withSonarQubeEnv('sonar-pro') { sh "${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=offers-spring-boot -Dsonar.projectName=offers-spring-boot" } } dir('shoes-microservice-spring-boot') { - def mvn = tool 'maven3'; + def mvn = tool 'maven3' withSonarQubeEnv('sonar-pro') { sh "${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=shoe-spring-boot -Dsonar.projectName=shoes-spring-boot" } } dir('zuul-api-gateway') { - def mvn = tool 'maven3'; + def mvn = tool 'maven3' withSonarQubeEnv('sonar-pro') { sh "${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=zuul-api -Dsonar.projectName=zuul-api" } @@ -49,21 +50,21 @@ pipeline { } }, 'python app': { - script{ + script { dir('wishlist-microservice-python') { - def scannerHome = tool 'sonarscanner4'; + def scannerHome = tool 'sonarscanner4' withSonarQubeEnv('sonar-pro') { sh """/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarscanner4/bin/sonar-scanner \ - -D sonar.projectVersion=1.0-SNAPSHOT \ - -D sonar.sources=. \ - -D sonar.login=admin \ - -D sonar.password=admin123 \ - -D sonar.projectKey=project \ - -D sonar.projectName=wishlist-py \ - -D sonar.inclusions=index.py \ - -D sonar.sourceEncoding=UTF-8 \ - -D sonar.language=python \ - -D sonar.host.url=http://13.232.29.132:9000/""" + -D sonar.projectVersion=1.0-SNAPSHOT \ + -D sonar.sources=. \ + -D sonar.login=admin \ + -D sonar.password=admin123 \ + -D sonar.projectKey=project \ + -D sonar.projectName=wishlist-py \ + -D sonar.inclusions=index.py \ + -D sonar.sourceEncoding=UTF-8 \ + -D sonar.language=python \ + -D sonar.host.url=http://localhost:9000/""" } } } @@ -71,73 +72,78 @@ pipeline { ) } } - stage ('Build Docker Image and push'){ + + stage('Build Docker Image and push') { steps { parallel ( 'docker login': { - withCredentials([string(credentialsId: 'dockerPass', variable: 'dockerPassword')]) { - sh "docker login -u comdevops -p ${dockerPassword}" + script { + // Directly assign Docker ID and password + def dockerId = 'ragesh2u' + + sh "docker login -u ${dockerId} -p ${dockerPassword}" } }, 'ui-web-app-reactjs': { - dir('ui-web-app-reactjs'){ + dir('ui-web-app-reactjs') { sh """ - docker build -t comdevops/ui:v1 . - docker push comdevops/ui:v1 - docker rmi comdevops/ui:v1 + docker build -t ragesh2u/ui:v1 . + docker push ragesh2u/ui:v1 + docker rmi ragesh2u/ui:v1 """ } }, - 'zuul-api-gateway' : { - dir('zuul-api-gateway'){ + 'zuul-api-gateway': { + dir('zuul-api-gateway') { sh """ - docker build -t comdevops/api:v1 . - docker push comdevops/api:v1 - docker rmi comdevops/api:v1 + docker build -t ragesh2u/api:v1 . + docker push ragesh2u/api:v1 + docker rmi ragesh2u/api:v1 """ } }, 'offers-microservice-spring-boot': { - dir('offers-microservice-spring-boot'){ + dir('offers-microservice-spring-boot') { sh """ - docker build -t comdevops/spring:v1 . - docker push comdevops/spring:v1 - docker rmi comdevops/spring:v1 + docker build -t ragesh2u/spring:v1 . + docker push ragesh2u/spring:v1 + docker rmi ragesh2u/spring:v1 """ } }, 'shoes-microservice-spring-boot': { - dir('shoes-microservice-spring-boot'){ + dir('shoes-microservice-spring-boot') { sh """ - docker build -t comdevops/spring:v2 . - docker push comdevops/spring:v2 - docker rmi comdevops/spring:v2 + docker build -t ragesh2u/springs:v2 . + docker push ragesh2u/springs:v2 + docker rmi ragesh2u/springs:v2 """ } }, 'cart-microservice-nodejs': { - dir('cart-microservice-nodejs'){ + dir('cart-microservice-nodejs') { sh """ - docker build -t comdevops/ui:v2 . - docker push comdevops/ui:v2 - docker rmi comdevops/ui:v2 + docker build -t ragesh2u/ui:v2 . + docker push ragesh2u/ui:v2 + docker rmi ragesh2u/ui:v2 """ } }, 'wishlist-microservice-python': { - dir('wishlist-microservice-python'){ + dir('wishlist-microservice-python') { sh """ - docker build -t comdevops/python:v1 . - docker push comdevops/python:v1 - docker rmi comdevops/python:v1 + docker build -t ragesh2u/python:v1 . + docker push ragesh2u/python:v1 + docker rmi ragesh2u/python:v1 """ } } ) } } - stage ('Deploy on k8s'){ - steps{ + + stage('Deploy on k8s') { + steps { parallel ( 'deploy on k8s': { script { diff --git a/cart-microservice-nodejs/sonar-project.properties b/cart-microservice-nodejs/sonar-project.properties index 37c5808..11c82d5 100644 --- a/cart-microservice-nodejs/sonar-project.properties +++ b/cart-microservice-nodejs/sonar-project.properties @@ -3,7 +3,7 @@ sonar.projectName=cart-nodejs sonar.projectVersion=1.0 sonar.sources=. sonar.sourceEncoding=UTF-8 -sonar.host.url=http://13.232.29.132:9000/ -sonar.login=sqa_c8bbd62d3cff72d97c520a1488aa4411d1fc43d0 -sonar.exclusions=**/node_modules/**,/coverage/lcov-report/*,test/*.js +sonar.host.url=http://localhost:9000/ +sonar.login=sqa_83be965a417e830eace5a45e0ee24d0bbf977a9b +sonar.exclusions=**/node_modules/**;**/coverage/lcov-report/**;**/test/*.js sonar.javascript.lcov.reportPaths=coverage/lcov.info diff --git a/offers-microservice-spring-boot/Dockerfile b/offers-microservice-spring-boot/Dockerfile index d20bf2f..ce9039d 100644 --- a/offers-microservice-spring-boot/Dockerfile +++ b/offers-microservice-spring-boot/Dockerfile @@ -2,7 +2,7 @@ FROM maven as build USER root WORKDIR /app COPY . . -RUN mvn install +#RUN mvn install FROM openjdk:11.0.10-jre WORKDIR /app diff --git a/offers-microservice-spring-boot/sonar-project.properties b/offers-microservice-spring-boot/sonar-project.properties index b8cfad3..7a4be3b 100644 --- a/offers-microservice-spring-boot/sonar-project.properties +++ b/offers-microservice-spring-boot/sonar-project.properties @@ -3,7 +3,7 @@ sonar.projectName=offers-spring-boot sonar.projectVersion=1.0 sonar.sources=. sonar.sourceEncoding=UTF-8 -sonar.host.url=http://13.233.199.142:9000/ -sonar.login=sqa_e89ae5578b2355ebe83f42b11ecc77975b6234e1 +sonar.host.url=http://localhost:9000/ +sonar.login=sqa_83be965a417e830eace5a45e0ee24d0bbf977a9b sonar.exclusions=**/node_modules/**,/coverage/lcov-report/*,test/*.js sonar.javascript.lcov.reportPaths=coverage/lcov.info diff --git a/shoes-microservice-spring-boot/sonar-project.properties b/shoes-microservice-spring-boot/sonar-project.properties index 940f9ed..defabb6 100644 --- a/shoes-microservice-spring-boot/sonar-project.properties +++ b/shoes-microservice-spring-boot/sonar-project.properties @@ -3,7 +3,7 @@ sonar.projectName=shoe-spring-boot sonar.projectVersion=1.0 sonar.sources=. sonar.sourceEncoding=UTF-8 -sonar.host.url=http://13.233.199.142:9000/ -sonar.login=sqa_e89ae5578b2355ebe83f42b11ecc77975b6234e1 +sonar.host.url=http://localhost:9000/ +sonar.login=sqa_83be965a417e830eace5a45e0ee24d0bbf977a9b sonar.exclusions=**/node_modules/**,/coverage/lcov-report/*,test/*.js sonar.javascript.lcov.reportPaths=coverage/lcov.info diff --git a/ui-web-app-reactjs/Dockerfile b/ui-web-app-reactjs/Dockerfile index e70adfd..6122929 100644 --- a/ui-web-app-reactjs/Dockerfile +++ b/ui-web-app-reactjs/Dockerfile @@ -1,8 +1,8 @@ -FROM node:8 +FROM node:14 RUN echo " Try to build my application" COPY . /var/www WORKDIR /var/www #RUN npm install EXPOSE 3000 -# EXPOSE 31448 +EXPOSE 31448 ENTRYPOINT ["npm","start"] diff --git a/ui-web-app-reactjs/sonar-project.properties b/ui-web-app-reactjs/sonar-project.properties index 9316c61..90a68c3 100644 --- a/ui-web-app-reactjs/sonar-project.properties +++ b/ui-web-app-reactjs/sonar-project.properties @@ -8,9 +8,9 @@ sonar.sources=. sonar.sourceEncoding=UTF-8 -sonar.host.url=http://13.232.29.132:9000/ +sonar.host.url=http://localhost:9000/ -sonar.login=sqa_c8bbd62d3cff72d97c520a1488aa4411d1fc43d0 +sonar.login=sqa_83be965a417e830eace5a45e0ee24d0bbf977a9b sonar.exclusions=**/node_modules/**,/coverage/lcov-report/*,test/*.js diff --git a/ui-web-app-reactjs/src/components/App.jsx b/ui-web-app-reactjs/src/components/App.jsx index 5c732ae..fff79b1 100644 --- a/ui-web-app-reactjs/src/components/App.jsx +++ b/ui-web-app-reactjs/src/components/App.jsx @@ -23,8 +23,8 @@ const App = () => { },[]) const handleApiCall = async (e) => { - // const url = 'http://localhost:9999/'+e.target.name; - let url = 'http://13.232.78.19:32470/'+e.target.name + const url = 'http://localhost:9999/'+e.target.name; + //let url = 'http://13.232.78.19:32470/'+e.target.name displayData.url=url let options = {} diff --git a/vpc.py b/vpc.py new file mode 100644 index 0000000..26abfa2 --- /dev/null +++ b/vpc.py @@ -0,0 +1 @@ +import boto3 diff --git a/wishlist-microservice-python/sonar-project.properties b/wishlist-microservice-python/sonar-project.properties index 62b5f9b..0e8cf17 100644 --- a/wishlist-microservice-python/sonar-project.properties +++ b/wishlist-microservice-python/sonar-project.properties @@ -1,9 +1,14 @@ sonar.projectKey=wishlist-py + sonar.projectName=wishlist-py + sonar.projectVersion=1.0 + sonar.sources=. + sonar.sourceEncoding=UTF-8 -sonar.host.url=http://13.233.199.142:9000/ -sonar.login=sqa_e89ae5578b2355ebe83f42b11ecc77975b6234e1 + +sonar.host.url=http://localhost:9000/ +sonar.login=sqa_83be965a417e830eace5a45e0ee24d0bbf977a9b sonar.coverage.exclusions=**/__index__.py sonar.javascript.lcov.reportPaths=coverage/lcov.info diff --git a/zuul-api-gateway/sonar-project.properties b/zuul-api-gateway/sonar-project.properties index 42f6429..7c2d58b 100644 --- a/zuul-api-gateway/sonar-project.properties +++ b/zuul-api-gateway/sonar-project.properties @@ -3,7 +3,7 @@ sonar.projectName=zuul-api sonar.projectVersion=1.0 sonar.sources=. sonar.sourceEncoding=UTF-8 -sonar.host.url=http://13.233.199.142:9000/ -sonar.login=sqa_e89ae5578b2355ebe83f42b11ecc77975b6234e1 +sonar.host.url=http://localhost:9000/ +sonar.login=sqa_83be965a417e830eace5a45e0ee24d0bbf977a9b sonar.exclusions=**/node_modules/**,/coverage/lcov-report/*,test/*.js sonar.javascript.lcov.reportPaths=coverage/lcov.info