diff --git a/Jenkinsfile b/Jenkinsfile index be7508be5..21699aa64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,121 +1,123 @@ +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] pipeline { - agent any -/* tools { - maven "maven3" - } -*/ - environment { - NEXUS_VERSION = "nexus3" - NEXUS_PROTOCOL = "http" - NEXUS_URL = "172.31.40.209:8081" - NEXUS_REPOSITORY = "vprofile-release" - NEXUS_REPO_ID = "vprofile-release" - NEXUS_CREDENTIAL_ID = "nexuslogin" - ARTVERSION = "${env.BUILD_ID}" - } - - stages{ - - stage('BUILD'){ + maven "MAVEN3.9" + jdk "JDK17" + } + + stages { + + stage('test slack'){ + steps{ + sh 'NotARealCommand' + + } + } + stage('Fetch code') { steps { - sh 'mvn clean install -DskipTests' - } - post { - success { - echo 'Now Archiving...' - archiveArtifacts artifacts: '**/target/*.war' - } + git branch: 'cicd', url: 'https://github.com/jkabirqa/aheeva-project.git' } - } - stage('UNIT TEST'){ - steps { + } + + + stage('Build'){ + steps{ + sh 'mvn install -DskipTests' + } + + post { + success { + echo 'Now Archiving it...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + + stage('UNIT TEST') { + steps{ sh 'mvn test' } } - stage('INTEGRATION TEST'){ - steps { - sh 'mvn verify -DskipUnitTests' - } - } - - stage ('CODE ANALYSIS WITH CHECKSTYLE'){ - steps { + stage('Checkstyle Analysis') { + steps{ sh 'mvn checkstyle:checkstyle' } - post { - success { - echo 'Generated Analysis Result' - } - } } - stage('CODE ANALYSIS with SONARQUBE') { - - environment { - scannerHome = tool 'sonarscanner4' - } - - steps { - withSonarQubeEnv('sonar-pro') { - sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ - -Dsonar.projectName=vprofile-repo \ + stage("Sonar Code Analysis") { + environment { + scannerHome = tool 'sonar6.2' + } + steps { + withSonarQubeEnv('sonarserver') { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=aheeva \ -Dsonar.projectVersion=1.0 \ -Dsonar.sources=src/ \ - -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.java.binaries=target/test-classes/com/aheeva/account/controllerTest/ \ -Dsonar.junit.reportsPath=target/surefire-reports/ \ -Dsonar.jacoco.reportsPath=target/jacoco.exec \ -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } } + } - timeout(time: 10, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } } } - } - stage("Publish to Nexus Repository Manager") { - steps { - script { - pom = readMavenPom file: "pom.xml"; - filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); - echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" - artifactPath = filesByGlob[0].path; - artifactExists = fileExists artifactPath; - if(artifactExists) { - echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION"; - nexusArtifactUploader( - nexusVersion: NEXUS_VERSION, - protocol: NEXUS_PROTOCOL, - nexusUrl: NEXUS_URL, - groupId: pom.groupId, - version: ARTVERSION, - repository: NEXUS_REPOSITORY, - credentialsId: NEXUS_CREDENTIAL_ID, - artifacts: [ - [artifactId: pom.artifactId, - classifier: '', - file: artifactPath, - type: pom.packaging], - [artifactId: pom.artifactId, - classifier: '', - file: "pom.xml", - type: "pom"] - ] - ); - } - else { - error "*** File: ${artifactPath}, could not be found"; - } - } + /* ==== UI TESTING ==== */ + stage('UI-Test -Selenium'){ + steps{ + sh 'mvn -pl qa-tests/ui-tests test' + } + post{ + always{ + junit '**/ui-tests/target/surefire-reports/*.xml' + } + } + } + + stage("UploadArtifact"){ + steps{ + nexusArtifactUploader( + nexusVersion: 'nexus3', + protocol: 'http', + nexusUrl: '172.31.25.14:8081', + groupId: 'QA', + version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}", + repository: 'aheeva-project', + credentialsId: 'nexuslogin', + artifacts: [ + [artifactId: 'aheevaapp', + classifier: '', + file: 'target/aheeva-v2.war', + type: 'war'] + ] + ) } } - } + } + post { + always { + echo 'Slack Notifications.' + slackSend channel: '#devopscicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" + } + } -} +} \ No newline at end of file diff --git a/Jenkinsfile.txt b/Jenkinsfile.txt new file mode 100644 index 000000000..3cce19ffe --- /dev/null +++ b/Jenkinsfile.txt @@ -0,0 +1,111 @@ +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] +pipeline { + agent any + tools { + maven "MAVEN3.9" + jdk "JDK17" + } + + stages { + + stage('test slack'){ + steps{ + sh 'NotARealCommand' + + } + } + stage('Fetch code') { + steps { + git branch: 'atom', url: 'https://github.com/hkhcoder/vprofile-project.git' + } + + } + + + stage('Build'){ + steps{ + sh 'mvn install -DskipTests' + } + + post { + success { + echo 'Now Archiving it...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + + stage('UNIT TEST') { + steps{ + sh 'mvn test' + } + } + + stage('Checkstyle Analysis') { + steps{ + sh 'mvn checkstyle:checkstyle' + } + } + + stage("Sonar Code Analysis") { + environment { + scannerHome = tool 'sonar6.2' + } + steps { + withSonarQubeEnv('sonarserver') { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } + } + } + + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } + + stage("UploadArtifact"){ + steps{ + nexusArtifactUploader( + nexusVersion: 'nexus3', + protocol: 'http', + nexusUrl: '172.31.25.14:8081', + groupId: 'QA', + version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}", + repository: 'vprofile-repo', + credentialsId: 'nexuslogin', + artifacts: [ + [artifactId: 'vproapp', + classifier: '', + file: 'target/vprofile-v2.war', + type: 'war'] + ] + ) + } + } + + + } + + post { + always { + echo 'Slack Notifications.' + slackSend channel: '#devopscicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" + } + } + +} \ No newline at end of file diff --git a/PAAC_CI_DockerECR.groovy b/PAAC_CI_DockerECR.groovy new file mode 100644 index 000000000..6d89141b6 --- /dev/null +++ b/PAAC_CI_DockerECR.groovy @@ -0,0 +1,103 @@ +pipeline { + agent any + tools { + maven "MAVEN3.9" + jdk "JDK17" + } + + + environment { + registryCredential = 'ecr:us-east-1:awscreds' + imageName = "716657688884.dkr.ecr.us-east-1.amazonaws.com/vprofileappimg" + vprofileRegistry = "https://716657688884.dkr.ecr.us-east-1.amazonaws.com" + } + stages { + + stage('Fetch code') { + steps { + git branch: 'docker', url: 'https://github.com/hkhcoder/vprofile-project.git' + } + + } + + + stage('Build'){ + steps{ + sh 'mvn install -DskipTests' + } + + post { + success { + echo 'Now Archiving it...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + + stage('UNIT TEST') { + steps{ + sh 'mvn test' + } + } + + stage('Checkstyle Analysis') { + steps{ + sh 'mvn checkstyle:checkstyle' + } + } + + stage("Sonar Code Analysis") { + environment { + scannerHome = tool 'sonar6.2' + } + steps { + withSonarQubeEnv('sonarserver') { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } + } + } + + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } + + stage('Build App Image') { + steps { + + script { + dockerImage = docker.build( imageName + ":$BUILD_NUMBER", "./Docker-files/app/multistage/") + } + } + + } + + stage('Upload App Image') { + steps{ + script { + docker.withRegistry( vprofileRegistry, registryCredential ) { + dockerImage.push("$BUILD_NUMBER") + dockerImage.push('latest') + } + } + } + } + + stage('Remove Container Images'){ + steps{ + sh 'docker rmi -f $(docker images -a -q)' + } + } + + } +} \ No newline at end of file diff --git a/PAAC_CI_DockerECR.txt b/PAAC_CI_DockerECR.txt new file mode 100644 index 000000000..db022cba9 --- /dev/null +++ b/PAAC_CI_DockerECR.txt @@ -0,0 +1,97 @@ +pipeline { + agent any + tools { + maven "MAVEN3.9" + jdk "JDK17" + } + + + environment { + registryCredential = 'ecr:us-east-2:awscreds' + appRegistry = "951401132355.dkr.ecr.us-east-2.amazonaws.com/vprofileappimg" + vprofileRegistry = "https://951401132355.dkr.ecr.us-east-2.amazonaws.com" + } + stages { + + stage('Fetch code') { + steps { + git branch: 'docker', url: 'https://github.com/hkhcoder/vprofile-project.git' + } + + } + + + stage('Build'){ + steps{ + sh 'mvn install -DskipTests' + } + + post { + success { + echo 'Now Archiving it...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + + stage('UNIT TEST') { + steps{ + sh 'mvn test' + } + } + + stage('Checkstyle Analysis') { + steps{ + sh 'mvn checkstyle:checkstyle' + } + } + + stage("Sonar Code Analysis") { + environment { + scannerHome = tool 'sonar6.2' + } + steps { + withSonarQubeEnv('sonarserver') { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } + } + } + + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } + + stage('Build App Image') { + steps { + + script { + dockerImage = docker.build( appRegistry + ":$BUILD_NUMBER", "./Docker-files/app/multistage/") + } + } + + } + + stage('Upload App Image') { + steps{ + script { + docker.withRegistry( vprofileRegistry, registryCredential ) { + dockerImage.push("$BUILD_NUMBER") + dockerImage.push('latest') + } + } + } + } + + } +} \ No newline at end of file diff --git a/README.md b/README.md index 88fd3cbba..8977aaade 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ +<<<<<<< HEAD # Prerequisites -# +####### - JDK 11 - Maven 3 - MySQL 8 @@ -22,4 +23,264 @@ sql dump file: - db_backup.sql file is a mysql dump file.we have to import this dump to mysql db server - > mysql -u -p accounts < db_backup.sql +# Project Title +πŸš€ CI Pipeline with Jenkins, SonarQube, Nexus & Slack Notifications + +πŸ“˜ Overview + +This repository demonstrates an automated Continuous Integration (CI) pipeline using modern DevOps tools. +The pipeline ensures: + +Automated build & test workflow + +Static code analysis and quality gate checks + +Centralized artifact storage + +Real-time notifications to the development team + +Faster feedback loops and improved code quality + +πŸ—οΈ Pipeline Architecture +Developer β†’ GitHub β†’ Jenkins Pipeline + ↓ + SonarQube (Quality Scan) + ↓ + Maven Build & Test + ↓ + Nexus (Artifact Repo) + ↓ + Slack (Success / Failure Alerts) + +πŸ”§ Tools & Technologies +Tool Purpose +Jenkins Automates CI workflow +SonarQube Static code analysis & quality gates +Nexus Repository Manager Stores built artifacts +Slack Build status notifications +Maven Build and dependency management +GitHub Version control repository +Java 17 Application language +πŸ“‚ Jenkins Pipeline Stages +1. Checkout Code + +Pulls code from GitHub. + +2. Build with Maven + +Runs: + +mvn clean install + +3. Static Code Analysis (SonarQube) + +Runs: + +mvn sonar:sonar + +4. Quality Gate Check + +Fail pipeline if SonarQube quality gate fails. + +5. Publish Artifacts to Nexus + +Runs: + +mvn deploy + + +Artifacts are pushed to: + +/nexus/repository/releases +/nexus/repository/snapshots + +6. Slack Notifications + +Notifies success/failure in Slack channel. + +🧩 Jenkinsfile (Declarative Pipeline) +def COLOR_MAP = [ + 'SUCCESS': 'good', + 'FAILURE': 'danger', +] +pipeline { + agent any + tools { + maven "MAVEN3.9" + jdk "JDK17" + } + + stages { + + stage('test slack'){ + steps{ + sh 'NotARealCommand' + + } + } + stage('Fetch code') { + steps { + git branch: 'atom', url: 'https://github.com/hkhcoder/vprofile-project.git' + } + + } + + + stage('Build'){ + steps{ + sh 'mvn install -DskipTests' + } + + post { + success { + echo 'Now Archiving it...' + archiveArtifacts artifacts: '**/target/*.war' + } + } + } + + stage('UNIT TEST') { + steps{ + sh 'mvn test' + } + } + + stage('Checkstyle Analysis') { + steps{ + sh 'mvn checkstyle:checkstyle' + } + } + + stage("Sonar Code Analysis") { + environment { + scannerHome = tool 'sonar6.2' + } + steps { + withSonarQubeEnv('sonarserver') { + sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \ + -Dsonar.projectName=vprofile \ + -Dsonar.projectVersion=1.0 \ + -Dsonar.sources=src/ \ + -Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \ + -Dsonar.junit.reportsPath=target/surefire-reports/ \ + -Dsonar.jacoco.reportsPath=target/jacoco.exec \ + -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml''' + } + } + } + + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } + + stage("UploadArtifact"){ + steps{ + nexusArtifactUploader( + nexusVersion: 'nexus3', + protocol: 'http', + nexusUrl: '172.31.25.14:8081', + groupId: 'QA', + version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}", + repository: 'vprofile-repo', + credentialsId: 'nexuslogin', + artifacts: [ + [artifactId: 'vproapp', + classifier: '', + file: 'target/vprofile-v2.war', + type: 'war'] + ] + ) + } + } + + + } + + post { + always { + echo 'Slack Notifications.' + slackSend channel: '#devopscicd', + color: COLOR_MAP[currentBuild.currentResult], + message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}" + } + } + +} + +πŸ“¦ Nexus Repository Structure +nexus-repository/ +β”œβ”€β”€ snapshots/ +β”‚ └── project-name-1.0-SNAPSHOT.jar +└── releases/ + └── project-name-1.0.0.jar + +βœ”οΈ Prerequisites + +Before running the pipeline ensure: + +Jenkins + +Pipeline plugin + +Maven plugin + +SonarQube plugin + +Slack Notification plugin + +Credentials configured (GitHub, Nexus, Slack, SonarQube token) + +SonarQube + +Server running + +Project created + +Authentication token generated + +Nexus + +Release & Snapshot repositories created + +Slack + +Webhook or Jenkins Slack plugin configured + +πŸš€ How to Run the Pipeline + +Add this Jenkinsfile to your repository. + +Create a Jenkins Pipeline job β†’ β€œPipeline from SCM”. + +Enter Git repo URL and branch. + +Run build. + +Check: + +Jenkins console log + +SonarQube dashboard + +Nexus repo artifacts + +Slack channel notifications + +πŸŽ‰ Conclusion + +This CI pipeline provides: + +Automated builds + +Enforced code quality & security + +Artifact versioning + +Instant feedback to teams + +A strong foundation for end-to-end CI/CD diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index 6d2dcd6a9..e9c119cf3 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -1,3 +1,3 @@ [defaults] host_key_checking = False -timeout = 30 +timeout = 35 diff --git a/pipeline_diagram.png b/pipeline_diagram.png new file mode 100644 index 000000000..80dfdbed0 Binary files /dev/null and b/pipeline_diagram.png differ diff --git a/selenium-tests/SampleTest.java b/selenium-tests/SampleTest.java new file mode 100644 index 000000000..1a1641ec2 --- /dev/null +++ b/selenium-tests/SampleTest.java @@ -0,0 +1 @@ +public class SampleTest {} \ No newline at end of file diff --git a/selenium-tests/TestBase.java b/selenium-tests/TestBase.java new file mode 100644 index 000000000..525a7da0a --- /dev/null +++ b/selenium-tests/TestBase.java @@ -0,0 +1 @@ +public class TestBase {} \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..f9e6a6f7a --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ +sonar.projectKey=sample +sonar.sources=. \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c04343d72..ce90fca00 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,7 +9,7 @@ jdbc.password=admin123 memcached.active.host=mc01 memcached.active.port=11211 #For StandBy Host -memcached.standBy.host=127.0.0.2 +memcached.standBy.host=127.0.0.1 memcached.standBy.port=11211 #RabbitMq Configuration diff --git a/target/classes/accountsdb.sql b/target/classes/accountsdb.sql new file mode 100644 index 000000000..d224d810f --- /dev/null +++ b/target/classes/accountsdb.sql @@ -0,0 +1,104 @@ +-- MySQL dump 10.13 Distrib 5.7.18, for Linux (x86_64) +-- +-- Host: localhost Database: accounts +-- ------------------------------------------------------ +-- Server version 5.7.18-0ubuntu0.16.10.1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `role` +-- + +DROP TABLE IF EXISTS `role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `role` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `role` +-- + +LOCK TABLES `role` WRITE; +/*!40000 ALTER TABLE `role` DISABLE KEYS */; +INSERT INTO `role` VALUES (1,'ROLE_USER'); +/*!40000 ALTER TABLE `role` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) DEFAULT NULL, + `userEmail` varchar(255) DEFAULT NULL, + `password` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user` +-- + +LOCK TABLES `user` WRITE; +/*!40000 ALTER TABLE `user` DISABLE KEYS */; +INSERT INTO `user` VALUES (4,'admin_vp','admin@visualpathit.com','$2a$11$DSEIKJNrgPjG.iCYUwErvOkREtC67mqzQ.ogkZbc/KOW1OPOpZfY6'); +/*!40000 ALTER TABLE `user` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_role` +-- + +DROP TABLE IF EXISTS `user_role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_role` ( + `user_id` int(11) NOT NULL, + `role_id` int(11) NOT NULL, + PRIMARY KEY (`user_id`,`role_id`), + KEY `fk_user_role_roleid_idx` (`role_id`), + CONSTRAINT `fk_user_role_roleid` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_user_role_userid` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_role` +-- + +LOCK TABLES `user_role` WRITE; +/*!40000 ALTER TABLE `user_role` DISABLE KEYS */; +INSERT INTO `user_role` VALUES (4,1); +/*!40000 ALTER TABLE `user_role` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2017-08-28 10:50:51 diff --git a/target/classes/application.properties b/target/classes/application.properties new file mode 100644 index 000000000..ce90fca00 --- /dev/null +++ b/target/classes/application.properties @@ -0,0 +1,25 @@ +#JDBC Configutation for Database Connection +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://db01:3306/accounts?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull +jdbc.username=admin +jdbc.password=admin123 + +#Memcached Configuration For Active and StandBy Host +#For Active Host +memcached.active.host=mc01 +memcached.active.port=11211 +#For StandBy Host +memcached.standBy.host=127.0.0.1 +memcached.standBy.port=11211 + +#RabbitMq Configuration +rabbitmq.address=rmq01 +rabbitmq.port=5672 +rabbitmq.username=test +rabbitmq.password=test + +#Elasticesearch Configuration +elasticsearch.host =192.168.1.85 +elasticsearch.port =9300 +elasticsearch.cluster=vprofile +elasticsearch.node=vprofilenode diff --git a/target/classes/com/visualpathit/account/beans/Components.class b/target/classes/com/visualpathit/account/beans/Components.class new file mode 100644 index 000000000..5e3095d47 Binary files /dev/null and b/target/classes/com/visualpathit/account/beans/Components.class differ diff --git a/target/classes/com/visualpathit/account/controller/ElasticSearchController.class b/target/classes/com/visualpathit/account/controller/ElasticSearchController.class new file mode 100644 index 000000000..746f049a9 Binary files /dev/null and b/target/classes/com/visualpathit/account/controller/ElasticSearchController.class differ diff --git a/target/classes/com/visualpathit/account/controller/FileUploadController.class b/target/classes/com/visualpathit/account/controller/FileUploadController.class new file mode 100644 index 000000000..b5eb23f81 Binary files /dev/null and b/target/classes/com/visualpathit/account/controller/FileUploadController.class differ diff --git a/target/classes/com/visualpathit/account/controller/UserController.class b/target/classes/com/visualpathit/account/controller/UserController.class new file mode 100644 index 000000000..89fecc438 Binary files /dev/null and b/target/classes/com/visualpathit/account/controller/UserController.class differ diff --git a/target/classes/com/visualpathit/account/model/Role.class b/target/classes/com/visualpathit/account/model/Role.class new file mode 100644 index 000000000..929351b9c Binary files /dev/null and b/target/classes/com/visualpathit/account/model/Role.class differ diff --git a/target/classes/com/visualpathit/account/model/User.class b/target/classes/com/visualpathit/account/model/User.class new file mode 100644 index 000000000..0e90c2414 Binary files /dev/null and b/target/classes/com/visualpathit/account/model/User.class differ diff --git a/target/classes/com/visualpathit/account/repository/RoleRepository.class b/target/classes/com/visualpathit/account/repository/RoleRepository.class new file mode 100644 index 000000000..ea5943ffc Binary files /dev/null and b/target/classes/com/visualpathit/account/repository/RoleRepository.class differ diff --git a/target/classes/com/visualpathit/account/repository/UserRepository.class b/target/classes/com/visualpathit/account/repository/UserRepository.class new file mode 100644 index 000000000..e6e9ace0f Binary files /dev/null and b/target/classes/com/visualpathit/account/repository/UserRepository.class differ diff --git a/target/classes/com/visualpathit/account/service/ConsumerService.class b/target/classes/com/visualpathit/account/service/ConsumerService.class new file mode 100644 index 000000000..2efb215f0 Binary files /dev/null and b/target/classes/com/visualpathit/account/service/ConsumerService.class differ diff --git a/target/classes/com/visualpathit/account/service/ConsumerServiceImpl.class b/target/classes/com/visualpathit/account/service/ConsumerServiceImpl.class new file mode 100644 index 000000000..c10ffa849 Binary files /dev/null and b/target/classes/com/visualpathit/account/service/ConsumerServiceImpl.class differ diff --git a/target/classes/com/visualpathit/account/service/ProducerService.class b/target/classes/com/visualpathit/account/service/ProducerService.class new file mode 100644 index 000000000..36065ad5f Binary files /dev/null and b/target/classes/com/visualpathit/account/service/ProducerService.class differ diff --git a/target/classes/com/visualpathit/account/service/ProducerServiceImpl.class b/target/classes/com/visualpathit/account/service/ProducerServiceImpl.class new file mode 100644 index 000000000..cfe2c6f06 Binary files /dev/null and b/target/classes/com/visualpathit/account/service/ProducerServiceImpl.class differ diff --git a/target/classes/com/visualpathit/account/service/SecurityService.class b/target/classes/com/visualpathit/account/service/SecurityService.class new file mode 100644 index 000000000..3dd66bfdb Binary files /dev/null and b/target/classes/com/visualpathit/account/service/SecurityService.class differ diff --git a/target/classes/com/visualpathit/account/service/SecurityServiceImpl.class b/target/classes/com/visualpathit/account/service/SecurityServiceImpl.class new file mode 100644 index 000000000..5f6244126 Binary files /dev/null and b/target/classes/com/visualpathit/account/service/SecurityServiceImpl.class differ diff --git a/target/classes/com/visualpathit/account/service/UserDetailsServiceImpl.class b/target/classes/com/visualpathit/account/service/UserDetailsServiceImpl.class new file mode 100644 index 000000000..2b6dbe5b0 Binary files /dev/null and b/target/classes/com/visualpathit/account/service/UserDetailsServiceImpl.class differ diff --git a/target/classes/com/visualpathit/account/service/UserService.class b/target/classes/com/visualpathit/account/service/UserService.class new file mode 100644 index 000000000..35f247faf Binary files /dev/null and b/target/classes/com/visualpathit/account/service/UserService.class differ diff --git a/target/classes/com/visualpathit/account/service/UserServiceImpl.class b/target/classes/com/visualpathit/account/service/UserServiceImpl.class new file mode 100644 index 000000000..68c463792 Binary files /dev/null and b/target/classes/com/visualpathit/account/service/UserServiceImpl.class differ diff --git a/target/classes/com/visualpathit/account/utils/ElasticsearchUtil.class b/target/classes/com/visualpathit/account/utils/ElasticsearchUtil.class new file mode 100644 index 000000000..36805dc9e Binary files /dev/null and b/target/classes/com/visualpathit/account/utils/ElasticsearchUtil.class differ diff --git a/target/classes/com/visualpathit/account/utils/MemcachedUtils.class b/target/classes/com/visualpathit/account/utils/MemcachedUtils.class new file mode 100644 index 000000000..8b7738c25 Binary files /dev/null and b/target/classes/com/visualpathit/account/utils/MemcachedUtils.class differ diff --git a/target/classes/com/visualpathit/account/utils/RabbitMqUtil.class b/target/classes/com/visualpathit/account/utils/RabbitMqUtil.class new file mode 100644 index 000000000..5c144de0d Binary files /dev/null and b/target/classes/com/visualpathit/account/utils/RabbitMqUtil.class differ diff --git a/target/classes/com/visualpathit/account/validator/UserValidator.class b/target/classes/com/visualpathit/account/validator/UserValidator.class new file mode 100644 index 000000000..3bc9554b5 Binary files /dev/null and b/target/classes/com/visualpathit/account/validator/UserValidator.class differ diff --git a/target/classes/db_backup.sql b/target/classes/db_backup.sql new file mode 100644 index 000000000..2f17a4df3 --- /dev/null +++ b/target/classes/db_backup.sql @@ -0,0 +1,133 @@ +-- MySQL dump 10.13 Distrib 5.7.18, for Linux (x86_64) +-- +-- Host: localhost Database: accounts +-- ------------------------------------------------------ +-- Server version 5.7.18-0ubuntu0.16.10.1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `role` +-- + +DROP TABLE IF EXISTS `role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `role` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `role` +-- + +LOCK TABLES `role` WRITE; +/*!40000 ALTER TABLE `role` DISABLE KEYS */; +INSERT INTO `role` VALUES (1,'ROLE_USER'); +/*!40000 ALTER TABLE `role` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) DEFAULT NULL, + `userEmail` varchar(255) DEFAULT NULL, + `profileImg` varchar(255) DEFAULT NULL, + `profileImgPath` varchar(255) DEFAULT NULL, + `dateOfBirth` varchar(255) DEFAULT NULL, + `fatherName` varchar(255) DEFAULT NULL, + `motherName` varchar(255) DEFAULT NULL, + `gender` varchar(255) DEFAULT NULL, + `maritalStatus` varchar(255) DEFAULT NULL, + `permanentAddress` varchar(255) DEFAULT NULL, + `tempAddress` varchar(255) DEFAULT NULL, + `primaryOccupation` varchar(255) DEFAULT NULL, + `secondaryOccupation` varchar(255) DEFAULT NULL, + `skills` varchar(255) DEFAULT NULL, + `phoneNumber` varchar(255) DEFAULT NULL, + `secondaryPhoneNumber` varchar(255) DEFAULT NULL, + `nationality` varchar(255) DEFAULT NULL, + `language` varchar(255) DEFAULT NULL, + `workingExperience` varchar(255) DEFAULT NULL, + `password` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user` +-- + +LOCK TABLES `user` WRITE; +/*!40000 ALTER TABLE `user` DISABLE KEYS */; + +INSERT INTO `user` VALUES (7,'admin_vp','admin@hkhinfo.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'$2a$11$0a7VdTr4rfCQqtsvpng6GuJnzUmQ7gZiHXgzGPgm5hkRa3avXgBLK') +,(8,'Abrar Nirban','abrar.nirban74@gmail.com',NULL,NULL,'27/01/2002','A nirban','T nirban','male','unMarried','Dubai,UAE','Dubai,UAE','Software Engineer','Software Engineer','Java HTML CSS ','8888888888','8888888888','Indian','english','2 ','$2a$11$UgG9TkHcgl02LxlqxRHYhOf7Xv4CxFmFEgS0FpUdk42OeslI.6JAW'), +(9,'Amayra Fatima','amayra@gmail.com',NULL,NULL,'20/06/1993','K','L','female','unMarried','Dubai,UAE','Dubai,UAE','Software Engineer','Software Engineer','Java HTML CSS ','9999999999','9999999999','India','english','5','$2a$11$gwvsvUrFU.YirMM1Yb7NweFudLUM91AzH5BDFnhkNzfzpjG.FplYO'), +(10,'Aron','aron.DSilva@gmail.com',NULL,NULL,'27/01/2002','M nirban','R nirban','male','unMarried','Dubai,UAE','Dubai,UAE','Software Engineer','Software Engineer','Java HTML CSS ','7777777777','777777777','India','english','7','$2a$11$6oZEgfGGQAH23EaXLVZ2WOSKxcEJFnBSw2N2aghab0s2kcxSQwjhC'), +(11,'Kiran Kumar','kiran@gmail.com',NULL,NULL,'8/12/1993','K K','RK','male','unMarried','SanFrancisco','James Street','Software Engineer','Software Engineer','Java HTML CSS ','1010101010','1010101010','India','english','10','$2a$11$EXwpna1MlFFlKW5ut1iVi.AoeIulkPPmcOHFO8pOoQt1IYU9COU0m'), +(12,'Balbir Singh','balbir@gmail.com',NULL,NULL,'20/06/1993','balbir RK','balbir AK','male','unMarried','SanFrancisco','US','Software Engineer','Software Engineer','Java HTML CSS AWS','8888888111','8888888111','India','english','8','$2a$11$pzWNzzR.HUkHzz2zhAgqOeCl0WaTgY33NxxJ7n0l.rnEqjB9JO7vy'), +(4,'Hibo Prince','hibo.prince@gmail.com',NULL,NULL,'6/09/2000','Abara','Queen','male','unMarried','Electronic City,UAE','Electronic City,UAE','Tester','Freelancing','Python PHP ','9146389863','9146389871','Indian','hindi','3 ','$2a$11$UgG9TkHcgl02LxlqxRHYhOf7Xv4CxFmFEgS0FpUdk42OeslI.6JAR'), +(5,'Aejaaz Habeeb','aejaaz.habeeb@gmail.com',NULL,NULL,'16/02/2001','Imran','Ziya','male','unMarried','AbuDhabi,UAE','AbuDhabi,UAE','Developer','Developer','Azure Devops ','9566489863','9566489863','Indian','hindi','4 ','$2a$11$UgG9TkHcgl02LxlqxRHYhOf7Xv4CxFmFEgS0FpUdk42OeslI.6JAR'), +(6,'Jackie','jackie.chan@gmail.com',NULL,NULL,'28/09/1992','Charles','Chan','male','Married','HongKong,China','HongKong,China','MartialArtist','MartialArtist','KungFu ','9246488863','9246488863','Chinese','Mandrian','1 ','$2a$11$UgG9TkHcgl02LxlqxRHYhOf7Xv4CxFmFEgS0FpUdk42OeslI.6RAR'), +(13,'Srinath Goud','sgoud@gmail.com',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'$2a$11$6BSmYPrT8I8b9yHmx.uTRu/QxnQM2vhZYQa8mR33aReWA4WFihyGK'); + + +/*!40000 ALTER TABLE `user` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_role` +-- + +DROP TABLE IF EXISTS `user_role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_role` ( + `user_id` int(11) NOT NULL, + `role_id` int(11) NOT NULL, + PRIMARY KEY (`user_id`,`role_id`), + KEY `fk_user_role_roleid_idx` (`role_id`), + CONSTRAINT `fk_user_role_roleid` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_user_role_userid` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_role` +-- + +LOCK TABLES `user_role` WRITE; +/*!40000 ALTER TABLE `user_role` DISABLE KEYS */; +INSERT INTO `user_role` VALUES (4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1); +/*!40000 ALTER TABLE `user_role` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2023-21-06 05:49:31 diff --git a/target/classes/logback.xml b/target/classes/logback.xml new file mode 100644 index 000000000..35b81df4d --- /dev/null +++ b/target/classes/logback.xml @@ -0,0 +1,24 @@ + + + + + + + %date{HH:mm:ss.SSS} [%thread] %-5level %logger{15}#%line %msg\n + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/classes/validation.properties b/target/classes/validation.properties new file mode 100644 index 000000000..0453cdd3a --- /dev/null +++ b/target/classes/validation.properties @@ -0,0 +1,5 @@ +NotEmpty=This field is required. +Size.userForm.username=Please use between 6 and 32 characters. +Duplicate.userForm.username= User has already taken this Username. +Size.userForm.password=Try one with at least 8 characters. +Diff.userForm.passwordConfirm=These passwords don't match. \ No newline at end of file diff --git a/target/test-classes/com/visualpathit/account/controllerTest/SampleTest.class b/target/test-classes/com/visualpathit/account/controllerTest/SampleTest.class new file mode 100644 index 000000000..00fd98a02 Binary files /dev/null and b/target/test-classes/com/visualpathit/account/controllerTest/SampleTest.class differ diff --git a/target/test-classes/com/visualpathit/account/controllerTest/UserControllerTest.class b/target/test-classes/com/visualpathit/account/controllerTest/UserControllerTest.class new file mode 100644 index 000000000..0fc899186 Binary files /dev/null and b/target/test-classes/com/visualpathit/account/controllerTest/UserControllerTest.class differ diff --git a/target/test-classes/com/visualpathit/account/modelTest/RoleTest.class b/target/test-classes/com/visualpathit/account/modelTest/RoleTest.class new file mode 100644 index 000000000..3851d4ffb Binary files /dev/null and b/target/test-classes/com/visualpathit/account/modelTest/RoleTest.class differ diff --git a/target/test-classes/com/visualpathit/account/modelTest/UserTest.class b/target/test-classes/com/visualpathit/account/modelTest/UserTest.class new file mode 100644 index 000000000..fc0166942 Binary files /dev/null and b/target/test-classes/com/visualpathit/account/modelTest/UserTest.class differ diff --git a/target/test-classes/com/visualpathit/account/setup/StandaloneMvcTestViewResolver.class b/target/test-classes/com/visualpathit/account/setup/StandaloneMvcTestViewResolver.class new file mode 100644 index 000000000..74a522193 Binary files /dev/null and b/target/test-classes/com/visualpathit/account/setup/StandaloneMvcTestViewResolver.class differ diff --git a/userdata/jenkins-setup.sh b/userdata/jenkins-setup.sh new file mode 100644 index 000000000..554c539e4 --- /dev/null +++ b/userdata/jenkins-setup.sh @@ -0,0 +1,15 @@ +#!/bin/bash +sudo apt update + +sudo apt install openjdk-17-jdk -y + +sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \ +https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key + +echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \ +https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ +/etc/apt/sources.list.d/jenkins.list > /dev/null + +sudo apt-get update + +sudo apt-get install jenkins -y diff --git a/userdata/nexus-setup.sh b/userdata/nexus-setup.sh new file mode 100644 index 000000000..c6477971f --- /dev/null +++ b/userdata/nexus-setup.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +sudo rpm --import https://yum.corretto.aws/corretto.key +sudo curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo + +sudo yum install -y java-17-amazon-corretto-devel wget -y + +mkdir -p /opt/nexus/ +mkdir -p /tmp/nexus/ +cd /tmp/nexus/ +NEXUSURL="https://download.sonatype.com/nexus/3/nexus-unix-x86-64-3.78.0-14.tar.gz" +wget $NEXUSURL -O nexus.tar.gz +sleep 10 +EXTOUT=`tar xzvf nexus.tar.gz` +NEXUSDIR=`echo $EXTOUT | cut -d '/' -f1` +sleep 5 +rm -rf /tmp/nexus/nexus.tar.gz +cp -r /tmp/nexus/* /opt/nexus/ +sleep 5 +useradd nexus +chown -R nexus.nexus /opt/nexus +cat <> /etc/systemd/system/nexus.service +[Unit] +Description=nexus service +After=network.target + +[Service] +Type=forking +LimitNOFILE=65536 +ExecStart=/opt/nexus/$NEXUSDIR/bin/nexus start +ExecStop=/opt/nexus/$NEXUSDIR/bin/nexus stop +User=nexus +Restart=on-abort + +[Install] +WantedBy=multi-user.target + +EOT + +echo 'run_as_user="nexus"' > /opt/nexus/$NEXUSDIR/bin/nexus.rc +systemctl daemon-reload +systemctl start nexus +systemctl enable nexus diff --git a/userdata/sonar-analysis-properties b/userdata/sonar-analysis-properties new file mode 100644 index 000000000..8751fe7fd --- /dev/null +++ b/userdata/sonar-analysis-properties @@ -0,0 +1,10 @@ +sonar.projectKey=vprofile +sonar.projectName=vprofile-repo +sonar.projectVersion=1.0 +sonar.sources=src/ +sonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ +sonar.junit.reportsPath=target/surefire-reports/ +sonar.jacoco.reportsPath=target/jacoco.exec +sonar.java.checkstyle.reportPaths=target/checkstyle-result.xml + + diff --git a/userdata/sonar-setup.sh b/userdata/sonar-setup.sh new file mode 100644 index 000000000..bfc4a634b --- /dev/null +++ b/userdata/sonar-setup.sh @@ -0,0 +1,119 @@ +#!/bin/bash +cp /etc/sysctl.conf /root/sysctl.conf_backup +cat < /etc/sysctl.conf +vm.max_map_count=262144 +fs.file-max=65536 +ulimit -n 65536 +ulimit -u 4096 +EOT +cp /etc/security/limits.conf /root/sec_limit.conf_backup +cat < /etc/security/limits.conf +sonarqube - nofile 65536 +sonarqube - nproc 409 +EOT + +sudo apt-get update -y +sudo apt-get install openjdk-17-jdk -y +sudo update-alternatives --config java + +java -version + +sudo apt update +wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - + +sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' +sudo apt install postgresql postgresql-contrib -y +#sudo -u postgres psql -c "SELECT version();" +sudo systemctl enable postgresql.service +sudo systemctl start postgresql.service +sudo echo "postgres:admin123" | chpasswd +runuser -l postgres -c "createuser sonar" +sudo -i -u postgres psql -c "ALTER USER sonar WITH ENCRYPTED PASSWORD 'admin123';" +sudo -i -u postgres psql -c "CREATE DATABASE sonarqube OWNER sonar;" +sudo -i -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE sonarqube to sonar;" +systemctl restart postgresql +#systemctl status -l postgresql +netstat -tulpena | grep postgres +sudo mkdir -p /sonarqube/ +cd /sonarqube/ +sudo curl -O https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.8.100196.zip +sudo apt-get install zip -y +sudo unzip -o sonarqube-9.9.8.100196.zip -d /opt/ +sudo mv /opt/sonarqube-9.9.8.100196/ /opt/sonarqube +sudo groupadd sonar +sudo useradd -c "SonarQube - User" -d /opt/sonarqube/ -g sonar sonar +sudo chown sonar:sonar /opt/sonarqube/ -R +cp /opt/sonarqube/conf/sonar.properties /root/sonar.properties_backup +cat < /opt/sonarqube/conf/sonar.properties +sonar.jdbc.username=sonar +sonar.jdbc.password=admin123 +sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube +sonar.web.host=0.0.0.0 +sonar.web.port=9000 +sonar.web.javaAdditionalOpts=-server +sonar.search.javaOpts=-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError +sonar.log.level=INFO +sonar.path.logs=logs +EOT + +cat < /etc/systemd/system/sonarqube.service +[Unit] +Description=SonarQube service +After=syslog.target network.target + +[Service] +Type=forking + +ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start +ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop + +User=sonar +Group=sonar +Restart=always + +LimitNOFILE=65536 +LimitNPROC=4096 + + +[Install] +WantedBy=multi-user.target +EOT + +systemctl daemon-reload +systemctl enable sonarqube.service +#systemctl start sonarqube.service +#systemctl status -l sonarqube.service +apt-get install nginx -y +rm -rf /etc/nginx/sites-enabled/default +rm -rf /etc/nginx/sites-available/default +cat < /etc/nginx/sites-available/sonarqube +server{ + listen 80; + server_name sonarqube.groophy.in; + + access_log /var/log/nginx/sonar.access.log; + error_log /var/log/nginx/sonar.error.log; + + proxy_buffers 16 64k; + proxy_buffer_size 128k; + + location / { + proxy_pass http://127.0.0.1:9000; + proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; + proxy_redirect off; + + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto http; + } +} +EOT +ln -s /etc/nginx/sites-available/sonarqube /etc/nginx/sites-enabled/sonarqube +systemctl enable nginx.service +#systemctl restart nginx.service +sudo ufw allow 80,9000,9001/tcp + +echo "System reboot in 30 sec" +sleep 30 +reboot diff --git a/vagrant/Automated_provisioning_MacOSM1/Vagrantfile b/vagrant/Automated_provisioning_MacOSM1/Vagrantfile index b1e293cce..351529062 100644 --- a/vagrant/Automated_provisioning_MacOSM1/Vagrantfile +++ b/vagrant/Automated_provisioning_MacOSM1/Vagrantfile @@ -4,7 +4,7 @@ Vagrant.configure("2") do |config| ### DB vm #### config.vm.define "db01" do |db01| - db01.vm.box = "jacobw/fedora35-arm64" + db01.vm.box = "bandit145/centos_stream9_arm" db01.vm.hostname = "db01" db01.vm.network "private_network", ip: "192.168.56.25" db01.vm.provision "shell", path: "mysql.sh" @@ -13,7 +13,7 @@ Vagrant.configure("2") do |config| ### Memcache vm #### config.vm.define "mc01" do |mc01| - mc01.vm.box = "jacobw/fedora35-arm64" + mc01.vm.box = "bandit145/centos_stream9_arm" mc01.vm.hostname = "mc01" mc01.vm.network "private_network", ip: "192.168.56.24" mc01.vm.provision "shell", path: "memcache.sh" @@ -21,7 +21,7 @@ Vagrant.configure("2") do |config| ### RabbitMQ vm #### config.vm.define "rmq01" do |rmq01| - rmq01.vm.box = "jacobw/fedora35-arm64" + rmq01.vm.box = "bandit145/centos_stream9_arm" rmq01.vm.hostname = "rmq01" rmq01.vm.network "private_network", ip: "192.168.56.23" rmq01.vm.provision "shell", path: "rabbitmq.sh" @@ -29,7 +29,7 @@ Vagrant.configure("2") do |config| ### tomcat vm ### config.vm.define "app01" do |app01| - app01.vm.box = "jacobw/fedora35-arm64" + app01.vm.box = "bandit145/centos_stream9_arm" app01.vm.hostname = "app01" app01.vm.network "private_network", ip: "192.168.56.22" app01.vm.provision "shell", path: "tomcat.sh" diff --git a/vagrant/Automated_provisioning_MacOSM1/memcache.sh b/vagrant/Automated_provisioning_MacOSM1/memcache.sh index 86554fb72..8c4a33838 100644 --- a/vagrant/Automated_provisioning_MacOSM1/memcache.sh +++ b/vagrant/Automated_provisioning_MacOSM1/memcache.sh @@ -1,16 +1,13 @@ #!/bin/bash -mv /etc/yum.repos.d/fedora-updates.repo /tmp/ -mv /etc/yum.repos.d/fedora-updates-modular.repo /tmp/ -yum clean all -#yum update -sudo yum install epel-release -y -sudo yum install memcached -y +sudo dnf install epel-release -y +sudo dnf install memcached -y sudo systemctl start memcached sudo systemctl enable memcached sudo systemctl status memcached -firewall-cmd --add-port=11211/tcp --permanent -firewall-cmd --reload -sed -i 's/OPTIONS="-l 127.0.0.1"/OPTIONS=""/' /etc/sysconfig/memcached +sed -i 's/127.0.0.1/0.0.0.0/g' /etc/sysconfig/memcached sudo systemctl restart memcached - +firewall-cmd --add-port=11211/tcp +firewall-cmd --runtime-to-permanent +firewall-cmd --add-port=11111/udp +firewall-cmd --runtime-to-permanent sudo memcached -p 11211 -U 11111 -u memcached -d diff --git a/vagrant/Automated_provisioning_MacOSM1/mysql.sh b/vagrant/Automated_provisioning_MacOSM1/mysql.sh index d1e9b23cc..9beee3777 100644 --- a/vagrant/Automated_provisioning_MacOSM1/mysql.sh +++ b/vagrant/Automated_provisioning_MacOSM1/mysql.sh @@ -1,23 +1,18 @@ #!/bin/bash -sudo mv /etc/yum.repos.d/fedora-updates.repo /tmp/ -sudo mv /etc/yum.repos.d/fedora-updates-modular.repo /tmp/ -sudo yum clean all -#sudo yum update -y DATABASE_PASS='admin123' -#sudo yum install epel-release -y +sudo yum update -y +sudo yum install epel-release -y sudo yum install git zip unzip -y sudo yum install mariadb-server -y # starting & enabling mariadb-server - sudo systemctl start mariadb sudo systemctl enable mariadb cd /tmp/ git clone -b main https://github.com/hkhcoder/vprofile-project.git #restore the dump file for the application sudo mysqladmin -u root password "$DATABASE_PASS" -#sudo mysql -u root -p"$DATABASE_PASS" -e "UPDATE mysql.user SET Password=PASSWORD('$DATABASE_PASS') WHERE User='root'" sudo mysql -u root -p"$DATABASE_PASS" -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" sudo mysql -u root -p"$DATABASE_PASS" -e "DELETE FROM mysql.user WHERE User=''" sudo mysql -u root -p"$DATABASE_PASS" -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'" @@ -33,11 +28,9 @@ sudo systemctl restart mariadb #starting the firewall and allowing the mariadb to access from port no. 3306 -#sudo systemctl start firewalld -#sudo systemctl enable firewalld -#sudo firewall-cmd --get-active-zones -#sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent -#sudo firewall-cmd --reload -sudo systemctl stop firewalld -sudo systemctl disable firewalld +sudo systemctl start firewalld +sudo systemctl enable firewalld +sudo firewall-cmd --get-active-zones +sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent +sudo firewall-cmd --reload sudo systemctl restart mariadb diff --git a/vagrant/Automated_provisioning_MacOSM1/rabbitmq.sh b/vagrant/Automated_provisioning_MacOSM1/rabbitmq.sh index b37e17c9c..276aa53df 100644 --- a/vagrant/Automated_provisioning_MacOSM1/rabbitmq.sh +++ b/vagrant/Automated_provisioning_MacOSM1/rabbitmq.sh @@ -1,29 +1,18 @@ #!/bin/bash -sudo mv /etc/yum.repos.d/fedora-updates.repo /tmp/ -sudo mv /etc/yum.repos.d/fedora-updates-modular.repo /tmp/ -sudo yum clean all -#sudo yum update -y -echo "SElinux changes." -sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config -setenforce 0 -echo -echo -curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash -sudo yum clean all -sudo yum makecache -sudo yum install erlang -y -curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash -sudo yum install rabbitmq-server -y -rpm -qi rabbitmq-server -systemctl start rabbitmq-server +sudo yum install epel-release -y +sudo yum update -y +sudo yum install wget -y +cd /tmp/ +dnf -y install centos-release-rabbitmq-38 + dnf --enablerepo=centos-rabbitmq-38 -y install rabbitmq-server + systemctl enable --now rabbitmq-server + firewall-cmd --add-port=5672/tcp + firewall-cmd --runtime-to-permanent +sudo systemctl start rabbitmq-server sudo systemctl enable rabbitmq-server sudo systemctl status rabbitmq-server sudo sh -c 'echo "[{rabbit, [{loopback_users, []}]}]." > /etc/rabbitmq/rabbitmq.config' sudo rabbitmqctl add_user test test sudo rabbitmqctl set_user_tags test administrator -firewall-cmd --add-port=5671/tcp --permanent -firewall-cmd --add-port=5672/tcp --permanent -firewall-cmd --reload +rabbitmqctl set_permissions -p / test ".*" ".*" ".*" sudo systemctl restart rabbitmq-server -nohup sleep 30 && reboot & -echo "going to reboot now" diff --git a/vagrant/Automated_provisioning_MacOSM1/tomcat.sh b/vagrant/Automated_provisioning_MacOSM1/tomcat.sh index d337effd1..dd78a8cfd 100644 --- a/vagrant/Automated_provisioning_MacOSM1/tomcat.sh +++ b/vagrant/Automated_provisioning_MacOSM1/tomcat.sh @@ -1,10 +1,7 @@ -sudo mv /etc/yum.repos.d/fedora-updates.repo /tmp/ -sudo mv /etc/yum.repos.d/fedora-updates-modular.repo /tmp/ -sudo yum clean all -#sudo yum update -TOMURL="https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.tar.gz" -yum install java-11-openjdk java-11-openjdk-devel -y -yum install git maven wget -y +#!/bin/bash +TOMURL="https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.26/bin/apache-tomcat-10.1.26.tar.gz" +dnf -y install java-17-openjdk java-17-openjdk-devel +dnf install git wget rsync -y cd /tmp/ wget $TOMURL -O tomcatbin.tar.gz EXTOUT=`tar xzvf tomcatbin.tar.gz` @@ -49,15 +46,22 @@ EOT systemctl daemon-reload systemctl start tomcat systemctl enable tomcat +cd /tmp/ +wget https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip +unzip apache-maven-3.9.9-bin.zip +cp -r apache-maven-3.9.9 /usr/local/maven3.9 +export MAVEN_OPTS="-Xmx512m" -git clone -b main https://github.com/hkhcoder/vprofile-project.git +git clone -b local https://github.com/hkhcoder/vprofile-project.git cd vprofile-project -mvn install +/usr/local/maven3.9/bin/mvn install systemctl stop tomcat -sleep 60 +sleep 20 rm -rf /usr/local/tomcat/webapps/ROOT* cp target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war systemctl start tomcat -firewall-cmd --add-port=8080/tcp --permanent -firewall-cmd --reload +sleep 20 +systemctl stop firewalld +systemctl disable firewalld +#cp /vagrant/application.properties /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/application.properties systemctl restart tomcat diff --git a/vagrant/Automated_provisioning_WinMacIntel/rabbitmq.sh b/vagrant/Automated_provisioning_WinMacIntel/rabbitmq.sh index 2dc18b759..276aa53df 100644 --- a/vagrant/Automated_provisioning_WinMacIntel/rabbitmq.sh +++ b/vagrant/Automated_provisioning_WinMacIntel/rabbitmq.sh @@ -14,4 +14,5 @@ sudo systemctl status rabbitmq-server sudo sh -c 'echo "[{rabbit, [{loopback_users, []}]}]." > /etc/rabbitmq/rabbitmq.config' sudo rabbitmqctl add_user test test sudo rabbitmqctl set_user_tags test administrator +rabbitmqctl set_permissions -p / test ".*" ".*" ".*" sudo systemctl restart rabbitmq-server diff --git a/vagrant/Automated_provisioning_WinMacIntel/tomcat.sh b/vagrant/Automated_provisioning_WinMacIntel/tomcat.sh index d850df030..3420a184e 100644 --- a/vagrant/Automated_provisioning_WinMacIntel/tomcat.sh +++ b/vagrant/Automated_provisioning_WinMacIntel/tomcat.sh @@ -1,6 +1,7 @@ -TOMURL="https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.tar.gz" -dnf -y install java-11-openjdk java-11-openjdk-devel -dnf install git maven wget -y +#!/bin/bash +TOMURL="https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.26/bin/apache-tomcat-10.1.26.tar.gz" +dnf -y install java-17-openjdk java-17-openjdk-devel +dnf install git wget -y cd /tmp/ wget $TOMURL -O tomcatbin.tar.gz EXTOUT=`tar xzvf tomcatbin.tar.gz` @@ -45,10 +46,15 @@ EOT systemctl daemon-reload systemctl start tomcat systemctl enable tomcat +cd /tmp/ +wget https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip +unzip apache-maven-3.9.9-bin.zip +cp -r apache-maven-3.9.9 /usr/local/maven3.9 +export MAVEN_OPTS="-Xmx512m" -git clone -b main https://github.com/hkhcoder/vprofile-project.git +git clone -b local https://github.com/hkhcoder/vprofile-project.git cd vprofile-project -mvn install +/usr/local/maven3.9/bin/mvn install systemctl stop tomcat sleep 20 rm -rf /usr/local/tomcat/webapps/ROOT* diff --git a/vagrant/Manual_provisioning_MacOSM1/Vagrantfile b/vagrant/Manual_provisioning_MacOSM1/Vagrantfile index 8994972b6..66562416a 100644 --- a/vagrant/Manual_provisioning_MacOSM1/Vagrantfile +++ b/vagrant/Manual_provisioning_MacOSM1/Vagrantfile @@ -4,7 +4,7 @@ Vagrant.configure("2") do |config| ### DB vm #### config.vm.define "db01" do |db01| - db01.vm.box = "jacobw/fedora35-arm64" + db01.vm.box = "bandit145/centos_stream9_arm" db01.vm.hostname = "db01" db01.vm.network "private_network", ip: "192.168.56.25" db01.vm.provider "vmware_desktop" do |vmware| @@ -15,7 +15,7 @@ Vagrant.configure("2") do |config| ### Memcache vm #### config.vm.define "mc01" do |mc01| - mc01.vm.box = "jacobw/fedora35-arm64" + mc01.vm.box = "bandit145/centos_stream9_arm" mc01.vm.hostname = "mc01" mc01.vm.network "private_network", ip: "192.168.56.24" mc01.vm.provider "vmware_desktop" do |vmware| @@ -26,7 +26,7 @@ Vagrant.configure("2") do |config| ### RabbitMQ vm #### config.vm.define "rmq01" do |rmq01| - rmq01.vm.box = "jacobw/fedora35-arm64" + rmq01.vm.box = "bandit145/centos_stream9_arm" rmq01.vm.hostname = "rmq01" rmq01.vm.network "private_network", ip: "192.168.56.23" rmq01.vm.provider "vmware_desktop" do |vmware| @@ -37,7 +37,7 @@ Vagrant.configure("2") do |config| ### tomcat vm ### config.vm.define "app01" do |app01| - app01.vm.box = "jacobw/fedora35-arm64" + app01.vm.box = "bandit145/centos_stream9_arm" app01.vm.hostname = "app01" app01.vm.network "private_network", ip: "192.168.56.22" app01.vm.provider "vmware_desktop" do |vb| diff --git a/vagrant/Manual_provisioning_MacOSM1/VprofileProjectSetupMacM1M2.pdf b/vagrant/Manual_provisioning_MacOSM1/VprofileProjectSetupMacM1M2.pdf index 25ac98149..9a4d8394f 100644 Binary files a/vagrant/Manual_provisioning_MacOSM1/VprofileProjectSetupMacM1M2.pdf and b/vagrant/Manual_provisioning_MacOSM1/VprofileProjectSetupMacM1M2.pdf differ diff --git a/vagrant/Manual_provisioning_WinMacIntel/VprofileProjectSetupWindowsAndMacIntel.pdf b/vagrant/Manual_provisioning_WinMacIntel/VprofileProjectSetupWindowsAndMacIntel.pdf index 52f5e10a8..2b333120c 100644 Binary files a/vagrant/Manual_provisioning_WinMacIntel/VprofileProjectSetupWindowsAndMacIntel.pdf and b/vagrant/Manual_provisioning_WinMacIntel/VprofileProjectSetupWindowsAndMacIntel.pdf differ