Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 68 additions & 47 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
pipeline {

agent any
/*

tools {
maven "maven3"
maven "maven3.9"
}
*/

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}"
SNAP_REPO = 'vprofile-snapshot'

RELEASE_REPO = 'vprofile-release'
CENTRAL_REPO = 'vpro-maven-central'
NEXUSIP = '172.31.27.140'
NEXUSPORT = '8081'
NEXUS_GRP_REPO = 'vpro-maven-group'

NEXUS_CREDS = credentials('nexuslogin')
}

stages{
Expand Down Expand Up @@ -56,13 +58,13 @@ pipeline {
stage('CODE ANALYSIS with SONARQUBE') {

environment {
scannerHome = tool 'sonarscanner4'
scannerHome = tool 'sonarscanner4'
}

steps {
withSonarQubeEnv('sonar-pro') {
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \
-Dsonar.projectName=vprofile-repo \
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/ \
Expand All @@ -72,50 +74,69 @@ pipeline {
}

timeout(time: 10, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
waitForQualityGate abortPipeline: false
}
}
}


stage("Publish to Nexus Repository Manager") {
steps {
script {
def pom = readMavenPom file: "pom.xml"

def filesByGlob = findFiles(glob: "target/*.${pom.packaging}")
def artifactPath = filesByGlob[0].path

nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: '172.31.27.140:8081',
groupId: 'QA',
version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}",
repository: 'vprofile-release',
credentialsId: 'nexuslogin',
artifacts: [
[artifactId: pom.artifactId,
classifier: '',
file: artifactPath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: '',
file: "pom.xml",
type: "pom"]
]
)
}
}
}
stage('Ansible Deploy to staging'){
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";
}
}
ansiblePlaybook([
inventory : 'ansible/stage.inventory',
playbook : 'ansible/site.yml',
installation: 'ansible',
colorized : true,
credentialsId: 'applogin',
disableHostKeyChecking: true,
extraVars : [
USER: "${NEXUS_CREDS_USR}",
PASS: "${NEXUS_CREDS_PSW}",
nexusip: "172.31.27.140",
reponame: "vprofile-release",
groupid: "QA",
time: "${env.BUILD_TIMESTAMP}",
build: "${env.BUILD_ID}",
artifactid: "vproapp",
vprofile_version: "vproapp-${env.BUILD_ID}-${env.BUILD_TIMESTAMP}.war"
]
])
}
}

}

}


}

2 changes: 2 additions & 0 deletions ansible/stage.inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[app]
app02stg.vprofile.project ansible_python_interpreter=/usr/bin/python3.8
2 changes: 1 addition & 1 deletion ansible/vpro-app-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tasks:
- name: Download latest VProfile.war from nexus
get_url:
url: "http://{{USER}}:{{PASS}}@{{nexusip}}:8081/repository/{{reponame}}/{{groupid}}/{{time}}/{{build}}/{{vprofile_version}}"
url: "http://{{USER}}:{{PASS}}@{{nexusip}}:8081/repository/{{reponame}}/{{groupid}}/{{artifactid}}/{{build}}-{{time}}/{{vprofile_version}}"
dest: "/tmp/vproapp-{{vprofile_version}}"
register: wardeploy
tags:
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<spring-data-jpa.version>1.8.2.RELEASE</spring-data-jpa.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
<mysql-connector.version>8.0.32</mysql-connector.version>
<mysql-connector.version>8.0.22</mysql-connector.version>
<commons-dbcp.version>1.4</commons-dbcp.version>
<jstl.version>1.2</jstl.version>
<junit.version>4.10</junit.version>
Expand Down Expand Up @@ -208,4 +208,10 @@

</plugins>
</build>
<repositories>
<repository>
<id>${NEXUS-GRP-REPO}</id>
<url>http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/</url>
</repository>
</repositories>
</project>
38 changes: 38 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

<servers>
<server>
<id>${SNAP-REPO}</id>
<username>${NEXUS-USER}</username>
<password>${NEXUS-PASS}</password>
</server>
<server>
<id>${RELEASE-REPO}</id>
<username>${NEXUS-USER}</username>
<password>${NEXUS-PASS}</password>
</server>
<server>
<id>${CENTRAL-REPO}</id>
<username>${NEXUS-USER}</username>
<password>${NEXUS-PASS}</password>
</server>
<server>
<id>${NEXUS-GRP-REPO}</id>
<username>${NEXUS-USER}</username>
<password>${NEXUS-PASS}</password>
</server>
</servers>

<mirrors>
<mirror>
<id>${CENTRAL-REPO}</id>
<name>${CENTRAL-REPO}</name>
<url>http://${NEXUSIP}:${NEXUSPORT}/repository/${NEXUS-GRP-REPO}/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>

</settings>
104 changes: 104 additions & 0 deletions target/classes/accountsdb.sql
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions target/classes/application.properties
Original file line number Diff line number Diff line change
@@ -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.2
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading