Sunteți pe pagina 1din 6

properties([

parameters([string(defaultValue: 'PS Suite/emr/release%2F5.8.200',


description: '',
name: 'ORIGINAL_PROJECT_NAME'),
string(defaultValue: '1',
description: '',
name: 'ORIGINAL_PROJECT_BUILD_NUMBER'),
string(defaultValue: 'C:\\Jenkins\\ui_auto_archived_vdo',
description: '',
name: 'PSS_UI_VDO_HOME')]),
[$class: 'ThrottleJobProperty',
categories: [],
limitOneJobWithMatchingParams: false,
maxConcurrentPerNode: 0,
maxConcurrentTotal: 0,
paramsToUseForLimit: '',
throttleEnabled: false,
throttleOption: 'project'],
pipelineTriggers([])
])

/*
* This method is used to clone branch jenkins-imran to the C:\GIT folder
* The branch name is hard coded but it is possible to make it dynamic
* */
def checkOutLatestCodeInGIT(def nodeName){
timeout(20){

println("Doing a GIT Update of the test source code to the VM");


checkout([$class: 'GitSCM', branches: [[name: 'jenkins-imran']],
doGenerateSubmoduleConfigurations: false, extensions: [[$class:
'RelativeTargetDirectory', relativeTargetDir: 'C:\\GIT'], [$class:
'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId:
'bd50b873-48b4-4eca-9537-5aa89cd71cc1', url:
'ssh://git@srv.dev.telushealth.com:7999/ps/qa-automation.git']]])

}
}

/*
* This method is used to copy the zip folder with the war files and all the
plugins in
* the C:\Artifacts folder.
* */
def copyArtifact(nodeName){
node(nodeName){
timeout(30){
println("Copy Artificat for the node :"+nodeName);
step([$class: 'CopyArtifact',filter: '*', fingerprintArtifacts: true,
projectName: "${ORIGINAL_PROJECT_NAME}", selector: [$class:
'SpecificBuildSelector',
buildNumber: "${ORIGINAL_PROJECT_BUILD_NUMBER}"], target:
'C:\\Artifacts'])
println("Copying Artifact was successful for :"+nodeName);
}
}
}

/*
* This method cleans all the files before deploying new war file and the plugins
* */
def preDeployementScript(nodeName){
node(nodeName){
timeout(20){
println("Running the PSS Predeployement Script "+nodeName);
dir("C:\\GIT\\ci\\pss_ci"){
bat 'python pss_pre_deployment.py'
}
}
}
}
/*
* This method is used to copy the war file and the plugins to the dedicated
folders
* The plugin ins are hard coded, as we deploy the same plugins each time we deploy
a build
* */
def deployTheWarFilesAndPlugins(nodeName){

node(nodeName){
timeout(30){
plugins = " \"HealthPortal.jar\" \"HL7Handler.jar\" \"Interior
Health Lab Importer.jar\" \"NEON Importer.jar\" \"Rad-Logic
Importer.jar\" \"ReportManagerImporter.jar\" \"SJH Importer.jar\" \"SMHTO
Importer.jar\" \"Sunnybrook Importer.jar\" \"TWH Importer.jar\" \"WCH
Importer.jar\"";
command = "python pss_deployment.py"+plugins
println("Started Copying War Files and PSS Plugins on "+nodeName);
println("Sending the following command"+command);
dir("C:\\GIT\\ci\\pss_ci"){
bat command;
}
}
}
}
/*
* This method restores Database
* */
def restoreDatabase(nodeName){
node(nodeName){
timeout(30){
println("Restoring Database on "+nodeName);
dir("C:\\GIT\\ci\\pss_ci"){
bat 'python oracle_db_restore.py'
}
}
}
}
/*
* This method is used to turn on the tomcat and keeping on waiting until the
server is ready
* to be used, so it will running until the server is up and take the interrupt off
when the server if on
* */
def turnOnTomCat(nodeName){
node(nodeName){
timeout(70){
println("Restoring Database on "+nodeName);
dir("C:\\GIT\\ci\\pss_ci"){
bat 'python pss_post_deployment.py'
}
}
}
}
/*
* This method is for client side of the Jenkins, It runs the whole UI test
* */
def run_ci_tests(nodeName){
node(nodeName){
timeout(350){
println("Restoring Database on "+nodeName);
dir("C:\\GIT\\Ui"){
bat 'python run_ui_tests_jenkins.py'
}
}
}
}
/*
* This method copies file to a central repository
* */
def copyFilesToACentralRepository(nodeName){
node(nodeName){
timeout(20){
println("Copying Files to a central repository "+nodeName);
dir("C:\\GIT\\ci\\pss_ci"){
bat 'python file_synchronization.py'
}
}
}
}
/*
* This method is used to get rid of files which are in the repository for more
than 10 days
* */
def getRidOfOldFiles(nodeName){
node(nodeName){
timeout(20){
println("Cleaning up the repository "+nodeName);
dir("C:\\GIT\\ci\\pss_ci"){
bat 'python cleanup_repository.py'
}
}
}
}

stage('Regression Test'){

def serverName1 = "QA Automation Server 1"


def serverName2 = "QA Automation Server 2"
def serverName3 = "QA Automation Server 3"
def clientName1 = "QA Automation Client 1"
def clientName2 = "QA Automation Client 2"
def clientName3 = "QA Automation Client 3"
println("We are in the Regression Loop :")

parallel one:{
node(serverName1) {
println("Checking out the Latest GIT Code in the Node1 ");
// Deploy Snapshot
//deploySnapshot(serverName1);
//deploySnapshot(clientName1);
//GIT Fetch
//checkOutLatestCodeInGIT(serverName1);
// Running the pre-deployement script
//preDeployementScript(serverName1);
// Database Restore
//restoreDatabase(serverName1);
//Copy Artifact from Jenkins to the local folder
//copyArtifact(serverName1);
// Putting the War Files and Plugins in places
//deployTheWarFilesAndPlugins(serverName1);
// Turn on the Tomcat Server
//turnOnTomCat(serverName1);
node(clientName1) {
//checkOutLatestCodeInGIT(clientName1);
// Turn on the CI Tests in the client side
run_ci_tests(clientName1);
}

}
},

two: {
node(serverName2)
{
println("Checking out the Latest GIT Code in the Node 2");
// Deploy Snapshot
//deploySnapshot(serverName2);
//deploySnapshot(clientName2);
//GIT Fetch
//checkOutLatestCodeInGIT(serverName2);
// Running the pre-deployement script
//preDeployementScript(serverName2);
// Database Restore
//restoreDatabase(serverName2);
//Copy Artifact from Jenkins to the local folder
//copyArtifact(serverName2);
// Putting the War Files and Plugins in places
//deployTheWarFilesAndPlugins(serverName2);
//Turn on the Tomcat Server
//turnOnTomCat(serverName2);
node(clientName2) {
//checkOutLatestCodeInGIT(clientName2);
// Turn on the CI Tests in the client side
run_ci_tests(clientName2);
}
}

},

three: {
node(serverName3)
{
println("Checking out the Latest GIT Code in the Node 3");
// Deploy Snapshot
//deploySnapshot(serverName3);
//deploySnapshot(clientName3);
//GIT Fetch
//checkOutLatestCodeInGIT(serverName3);
// Running the pre-deployement script
//preDeployementScript(serverName3);
// Database Restore
//restoreDatabase(serverName3);
//Copy Artifact from Jenkins to the local folder
//copyArtifact(serverName3);
// Putting the War Files and Plugins in places
//deployTheWarFilesAndPlugins(serverName3);
// Turn on the Tomcat Server
//turnOnTomCat(serverName3);
node(clientName3) {
//checkOutLatestCodeInGIT(clientName3);
// Turn on the CI Tests in the client side
run_ci_tests(clientName3);
}

def deploySnapshot(nodeName){

node(nodeName){

String VMName = giveExactComputerName(nodeName);


String snapShotName = VMName+" SN1";
println("Server Name :"+VMName);
println("Server Name :"+snapShotName);

println("Putting on the Snapshot");


vSphere buildStep: [$class: 'RevertToSnapshot', snapshotName: snapShotName,
vm: VMName], serverName: 'vSphere'
println("SuCeSs!2@!2!");
}
}

def giveExactComputerName(nodeName){

println("Converting Computer name to VM Sphere equivalent VM name : "+nodeName);


if (nodeName =="QA Automation Server 1"){
return "QA-IST8";
}

else if (nodeName=="QA Automation Server 2"){


return "QA-Automation4";
}

else if (nodeName=="QA Automation Server 3"){


return "QA-Automation-21";
}

else if (nodeName=="QA Automation Client 1"){


return "QA-Win7-Pro-2";
}

else if (nodeName=="QA Automation Client 2"){


return "QA-Win7-Pro";
}

else if (nodeName=="QA Automation Client 3"){


return "QA-Win10-Auto21";
}
else{
return "QA-IST8";
}

S-ar putea să vă placă și