diff --git a/Dockerfile b/Dockerfile index 4a3d0e40a4..8c2edb4031 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,7 @@ -From tomcat:8-jre8 - -COPY ./target/hello-world.war /usr/local/tomcat/webapps +FROM ubuntu +RUN apt-get update +RUN apt-get install -y git +RUN git clone https://github.com/prajwal1691/hello-world.git +RUN apt-get install -y maven +WORKDIR /hello-world +RUN mvn clean install diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..0956e0ffe1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,30 @@ +pipeline { + agent any + + stages { + stage('CHECKOUT') { + steps { + git branch: 'main', url: 'https://github.com/prajwal1691/hello-world' + } + } + stage('BUILD') { + steps { + sh 'cd /var/jenkins_home/workspace/sonar' + sh 'mvn clean install' + } + } + stage('Sonarqube') { + environment { + scannerHome = tool 'SonarQubeScanner' + } + steps { + withSonarQubeEnv('sonarqube') { + sh "${scannerHome}/bin/sonar-scanner -Dsonar.java.binaries=/var/jenkins_home/workspace/sonar/target" + } + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } + } + } + } +} diff --git a/README.md b/README.md index 9568d2ec65..b10a1c0b0c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,7 @@ # Maven web application project - -### Clean fresh application code is available in hell-world-maven branch and hello-world-maven tag -To clone the hello-world-maven branch ``` -git clone -b hello-world-maven https://github.com/vigneshsweekaran/hello-world.git +# To generate the package ``` -### To generate the package +### mvn clean package ``` -mvn clean package -``` -### War file is generated in target/hello-world.war +# War file is generated in target/hello-world.war diff --git a/appspec.yml b/appspec.yml deleted file mode 100644 index be162347a6..0000000000 --- a/appspec.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: 0.0 -os: linux -# files: -# - source: / -# destination: /var/www/html/WordPress -hooks: - ApplicationStop: - - location: codedeploy/scripts/application_stop.sh - timeout: 300 - runas: root - BeforeInstall: - - location: codedeploy/scripts/before_install.sh - timeout: 300 - runas: root - AfterInstall: - - location: codedeploy/scripts/after_install.sh - timeout: 300 - runas: root - ApplicationStart: - - location: codedeploy/scripts/application_start.sh - timeout: 300 - runas: root - ValidateService: - - location: codedeploy/scripts/validate_service.sh - timeout: 3600 - runas: root diff --git a/buildspec.yml b/buildspec.yml deleted file mode 100644 index d7bf67a38a..0000000000 --- a/buildspec.yml +++ /dev/null @@ -1,50 +0,0 @@ -version: 0.2 - -env: - variables: - IMAGE_REPO_NAME: "hello-world" - AWS_ACCOUNT_ID: "616853969531" - parameter-store: - DOCKER_PASSWORD: /codeBuild/dockerPassword - -phases: - install: - runtime-versions: - java: corretto8 - commands: - - yum install -y maven - finally: - - java -version - - mvn --version - pre_build: - commands: - - echo Logging in to Dockerhub for docker pull limit... - - docker login -u vigneshsweekaran -p $DOCKER_PASSWORD - - echo Logging in to Amazon ECR... - - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com - build: - on-failure: ABORT - commands: - - echo Build started on `date` - - echo Maven build... - - mvn clean package - - echo Building the Docker image... - - docker build -t $IMAGE_REPO_NAME:$CODEBUILD_BUILD_NUMBER . - - docker tag $IMAGE_REPO_NAME:$CODEBUILD_BUILD_NUMBER $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$CODEBUILD_BUILD_NUMBER - - docker tag $IMAGE_REPO_NAME:$CODEBUILD_BUILD_NUMBER $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:latest - post_build: - on-failure: ABORT - commands: - - echo Build completed on `date` - - echo Pushing the Docker image... - - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$CODEBUILD_BUILD_NUMBER - - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:latest - - sed -i "s/aws_region/$AWS_DEFAULT_REGION/" codedeploy/scripts/application_start.sh - - sed -i "s/repository_url/$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/" codedeploy/scripts/application_start.sh - - sed -i "s/image_url/$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com\/$IMAGE_REPO_NAME:$CODEBUILD_BUILD_NUMBER/" codedeploy/scripts/application_start.sh - -artifacts: - files: - - appspec.yml - - codedeploy/scripts/* - name: hello-world-build-artifacts diff --git a/cicd/01-Jenkinsfile-helloworld b/cicd/01-Jenkinsfile-helloworld deleted file mode 100644 index e32bc9dda9..0000000000 --- a/cicd/01-Jenkinsfile-helloworld +++ /dev/null @@ -1,15 +0,0 @@ -pipeline { - agent any - stages { - stage ('Build') { - steps { - sh 'echo Hello Build stage' - } - } - stage ('Test') { - steps { - sh 'echo hello Test stage' - } - } - } -} diff --git a/cicd/02-Jenkinsfile-maven-build b/cicd/02-Jenkinsfile-maven-build deleted file mode 100644 index 0e3fd6f046..0000000000 --- a/cicd/02-Jenkinsfile-maven-build +++ /dev/null @@ -1,13 +0,0 @@ -pipeline { - agent any - tools { - maven 'maven-3.6.3' - } - stages { - stage ('Build') { - steps { - sh 'mvn clean package' - } - } - } -} diff --git a/cicd/03-Jenkinsfile-deploy-to-tomcat b/cicd/03-Jenkinsfile-deploy-to-tomcat deleted file mode 100644 index a3c7cf3c4f..0000000000 --- a/cicd/03-Jenkinsfile-deploy-to-tomcat +++ /dev/null @@ -1,20 +0,0 @@ -pipeline { - agent any - tools { - maven 'maven-3.6.3' - } - stages { - stage ('Build') { - steps { - sh 'mvn clean package' - } - } - stage ('Deploy') { - steps { - script { - deploy adapters: [tomcat9(credentialsId: 'tomcat_credential', path: '', url: 'http://dayal-test.letspractice.tk:8081')], contextPath: '/pipeline', onFailure: false, war: 'webapp/target/*.war' - } - } - } - } -} diff --git a/cicd/04-Jenkinsfile-docker-build-push-deploy-same-server b/cicd/04-Jenkinsfile-docker-build-push-deploy-same-server deleted file mode 100644 index 35fc338a7b..0000000000 --- a/cicd/04-Jenkinsfile-docker-build-push-deploy-same-server +++ /dev/null @@ -1,41 +0,0 @@ -pipeline { - agent any - tools { - maven 'maven-3.6.3' - } - environment { - DATE = new Date().format('yy.M') - TAG = "${DATE}.${BUILD_NUMBER}" - } - stages { - stage ('Build') { - steps { - sh 'mvn clean package' - } - } - stage('Docker Build') { - steps { - script { - docker.build("vigneshsweekaran/hello-world:${TAG}") - } - } - } - stage('Pushing Docker Image to Dockerhub') { - steps { - script { - docker.withRegistry('https://registry.hub.docker.com', 'docker_credential') { - docker.image("vigneshsweekaran/hello-world:${TAG}").push() - docker.image("vigneshsweekaran/hello-world:${TAG}").push("latest") - } - } - } - } - stage('Deploy'){ - steps { - sh "docker stop hello-world | true" - sh "docker rm hello-world | true" - sh "docker run --name hello-world -d -p 9004:8080 vigneshsweekaran/hello-world:${TAG}" - } - } - } -} diff --git a/cicd/05-Jenkinsfile-docker-build-push-to-artifactory b/cicd/05-Jenkinsfile-docker-build-push-to-artifactory deleted file mode 100644 index b2f97fa8da..0000000000 --- a/cicd/05-Jenkinsfile-docker-build-push-to-artifactory +++ /dev/null @@ -1,41 +0,0 @@ -pipeline { - agent any - tools { - maven 'maven-3.6.3' - } - environment { - DATE = new Date().format('yy.M') - TAG = "${DATE}.${BUILD_NUMBER}" - } - stages { - stage ('Build') { - steps { - sh 'mvn clean package' - } - } - stage('Docker Build') { - steps { - script { - docker.build("default-docker-local/hello-world:${TAG}") - } - } - } - stage('Pushing Docker Image to Jfrog Artifactory') { - steps { - script { - docker.withRegistry('https://vigneshsweekaran.jfrog.io', 'artifactory-credential') { - docker.image("default-docker-local/hello-world:${TAG}").push() - docker.image("default-docker-local/hello-world:${TAG}").push("latest") - } - } - } - } - stage('Deploy'){ - steps { - sh "docker stop hello-world | true" - sh "docker rm hello-world | true" - sh "docker run --name hello-world -d -p 9004:8080 vigneshsweekaran.jfrog.io/default-docker-local/hello-world:${TAG}" - } - } - } -} diff --git a/cicd/06-Jenkinsfile-docker-build-push-to-artifactory-condition b/cicd/06-Jenkinsfile-docker-build-push-to-artifactory-condition deleted file mode 100644 index 1382ebf84e..0000000000 --- a/cicd/06-Jenkinsfile-docker-build-push-to-artifactory-condition +++ /dev/null @@ -1,48 +0,0 @@ -pipeline { - agent any - tools { - maven 'maven-3.6.3' - } - parameters { - choice(name: 'dockerRegistry', choices: ['Dockerhub', 'JfrogArtifactory'], description: 'Select Docker Registry') - } - environment { - DATE = new Date().format('yy.M') - TAG = "${DATE}.${BUILD_NUMBER}" - } - stages { - stage ('Build') { - steps { - sh 'mvn clean package' - } - } - stage('Docker build and push to Dockerhub') { - when { - environment name: 'dockerRegistry', value: 'Dockerhub' - } - steps { - script { - docker.build("vigneshsweekaran/hello-world:${TAG}") - docker.withRegistry("https://registry.hub.docker.com", 'docker_credential') { - docker.image("vigneshsweekaran/hello-world:${TAG}").push() - docker.image("vigneshsweekaran/hello-world:${TAG}").push("latest") - } - } - } - } - stage('Docker build and push to Jfrog Artifactory') { - when { - environment name: 'dockerRegistry', value: 'JfrogArtifactory' - } - steps { - script { - docker.build("default-docker-local/hello-world:${TAG}") - docker.withRegistry('https://vigneshsweekaran.jfrog.io', 'artifactory-credential') { - docker.image("default-docker-local/hello-world:${TAG}").push() - docker.image("default-docker-local/hello-world:${TAG}").push("latest") - } - } - } - } - } -} \ No newline at end of file diff --git a/cicd/07-Jenkinsfile-docker-build-push-to-artifactory-condition-shared-library b/cicd/07-Jenkinsfile-docker-build-push-to-artifactory-condition-shared-library deleted file mode 100644 index 647df591cc..0000000000 --- a/cicd/07-Jenkinsfile-docker-build-push-to-artifactory-condition-shared-library +++ /dev/null @@ -1,29 +0,0 @@ -@Library('library') _ - -pipeline { - agent any - tools { - maven 'maven-3.6.3' - } - parameters { - choice(name: 'dockerRegistry', choices: ['Dockerhub', 'JfrogArtifactory'], description: 'Select Docker Registry') - } - environment { - DATE = new Date().format('yy.M') - TAG = "${DATE}.${BUILD_NUMBER}" - } - stages { - stage ('Build') { - steps { - sh 'mvn clean package' - } - } - stage('Docker build and push to Docker Registry') { - steps { - script { - dockerBuildPush("${params.dockerRegistry}") - } - } - } - } -} \ No newline at end of file diff --git a/cicd/08-Jenkinsfile-docker-build-push-deloy-different-server b/cicd/08-Jenkinsfile-docker-build-push-deloy-different-server deleted file mode 100644 index d1135717f3..0000000000 --- a/cicd/08-Jenkinsfile-docker-build-push-deloy-different-server +++ /dev/null @@ -1,48 +0,0 @@ -pipeline { - agent any - tools { - maven 'maven-3.6.3' - } - environment { - DATE = new Date().format('yy.M') - TAG = "${DATE}.${BUILD_NUMBER}" - } - stages { - stage ('Build') { - steps { - sh 'mvn clean package' - } - } - stage('Docker Build') { - steps { - script { - docker.build("vigneshsweekaran/hello-world:${TAG}") - } - } - } - stage('Pushing Docker Image to Dockerhub') { - steps { - script { - docker.withRegistry('https://registry.hub.docker.com', 'docker_credential') { - docker.image("vigneshsweekaran/hello-world:${TAG}").push() - docker.image("vigneshsweekaran/hello-world:${TAG}").push("latest") - } - } - } - } - stage('Deploy'){ - steps { - withCredentials([sshUserPrivateKey(credentialsId: 'vm-key', keyFileVariable: 'SSH_PRIVATE_KEY_PATH')]) { - sh '''ssh -i $SSH_PRIVATE_KEY_PATH -o StrictHostKeyChecking=no ubuntu@jenkins.oc.devopspilot.com < + - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - com.example + + com.mcnz.rps.web hello-world + 1.0 war - hello-world - http://maven.apache.org - 1.0-SNAPSHOT - hello-world - - ${project.artifactId} - - - - maven-compiler-plugin - - 1.6 - 1.6 - - - - org.mortbay.jetty - jetty-maven-plugin - - - + + + UTF-8 + 1.8 + 1.8 + + junit + junit + 4.11 + test + + + javax.servlet servlet-api 2.5 @@ -45,19 +39,57 @@ provided - - junit - junit - 3.8.1 - test - - - junit - junit - 4.12 - test - + + hello-world + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.0 + + maven-tomcat-war-deployment-server + http://43.204.36.46:8090/manager/text + /hello-world + + + + + + + + maven-clean-plugin + 3.0.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + + 1.8 + 1.8 + + + + maven-war-plugin + 3.2.0 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + diff --git a/sonar-project.properties b/sonar-project.properties index 75da54e320..584deb7d40 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,10 +1 @@ -# Required metadata -sonar.projectKey=hello-world -sonar.projectName=Hello World -sonar.projectVersion=1.0 - -# Source information -sonar.sources=src/main -sonar.sourceEncoding=UTF-8 -sonar.language=java -sonar.java.binaries=target/classes +sonar.projectKey=Test_scan diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 309db7885f..2873803cf6 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,2 +1,48 @@ -

Hello DevOps Engineers Welcome !!

-

Deployed by Raghav and vignesh on 5 aug at chennai

+ + + + + Website created by prajwal + + + +
+

Prajwal's Company

+ +
+
+
+

Our Products

+

Here is a list of our products:

+
    +
  • Matte Finish Paint
  • +
  • Satin Finish Paint
  • +
  • Gloss Finish Paint
  • +
  • Textured Finish Paint
  • +
+
+
+

About Us

+

We are a leading wall paint industry, providing high-quality paints for all your needs.

+
+
+

Contact Us

+
+ + + + +
+
+
+ + +