
pipeline {
    agent any
    environment {
        deployPath = "/var/www/vhosts/bizgaze.com/qa.Bizgaze.com"
    }
    stages {
		stage('Restore packages') {
            steps {
            	dir('unibase/platform.tenants') {
					git url: 'git@code.bizgaze.com:unibase/tenants.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.analytics') {
					git url: 'git@code.bizgaze.com:unibase/analytics.git', credentialsId: 'jenkins_ssh_key' 
				}
				dir('unibase/platform.apps') {
					git url: 'git@code.bizgaze.com:unibase/apps.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.automation') {
					git url: 'git@code.bizgaze.com:unibase/automation.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.common') {
					git url: 'git@code.bizgaze.com:unibase/common.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/core') {
					git url: 'git@code.bizgaze.com:unibase/core.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.datasources') {
					git url: 'git@code.bizgaze.com:unibase/datasources.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.gps') {
					git url: 'git@code.bizgaze.com:unibase/gps.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/helpers') {
					git url: 'git@code.bizgaze.com:unibase/helpers.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.integrations') {
					git url: 'git@code.bizgaze.com:unibase/integrations.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/mongdbprovider') {
					git url: 'git@code.bizgaze.com:unibase/mongodbprovider.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/mssqldbprovider') {
					git url: 'git@code.bizgaze.com:unibase/mssqldbprovider.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/pgsqldbprovider') {
					git url: 'git@code.bizgaze.com:unibase/pgsqldbprovider.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform') {
					git url: 'git@code.bizgaze.com:unibase/platform.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.server') {
					git url: 'git@code.bizgaze.com:unibase/platform.server.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.templates') {
					git url: 'git@code.bizgaze.com:unibase/templates.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/platform.themes') {
					git url: 'git@code.bizgaze.com:unibase/themes.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/unibase.reference') {
					git url: 'git@code.bizgaze.com:unibase/unibase.reference.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unibase/utilities') {
					git url: 'git@code.bizgaze.com:unibase/utilities.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('interface.web') {
					git url: 'https://code.bizgaze.com/unibase/web.git'
				}
				dir('bizgaze') {
					git url: 'git@code.bizgaze.com:bizgaze/solution.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/bizgaze.reference') {
					git url: 'https://code.bizgaze.com/bizgaze/bizgaze.reference.git'
				}
				dir('bizgaze/communications') {
					git url: 'git@code.bizgaze.com:bizgaze/communications.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/crm') {
					git url: 'git@code.bizgaze.com:bizgaze/crm.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/crm.companies') {
					git url: 'git@code.bizgaze.com:bizgaze/crm.companies.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/crm.contacts') {
					git url: 'git@code.bizgaze.com:bizgaze/crm.contacts.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/crm.routes') {
					git url: 'git@code.bizgaze.com:bizgaze/crm.routes.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/integration.gst') {
					git url: 'git@code.bizgaze.com:bizgaze/integration.gst.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/integration.tally') {
					git url: 'git@code.bizgaze.com:bizgaze/Integration.Tally.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/paybacks') {
					git url: 'git@code.bizgaze.com:bizgaze/paybacks.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/pm') {
					git url: 'git@code.bizgaze.com:bizgaze/pm.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/support') {
					git url: 'git@code.bizgaze.com:bizgaze/support.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/tm') {
					git url: 'git@code.bizgaze.com:bizgaze/tm.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.accounting') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.accounting.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.automation') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.automation.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.coupons') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.coupons.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.estimates') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.estimates.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.expenses') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.expenses.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.inventory') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.inventory.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.invoices') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.invoices.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.offers') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.offers.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.orders') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.orders.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.payments') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.payments.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.pricelists') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.pricelists.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.providers') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.providers.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.taxes') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.taxes.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('bizgaze/transact.wallets') {
					git url: 'git@code.bizgaze.com:bizgaze/transact.wallets.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('uniconnect') {
					git url: 'git@code.bizgaze.com:unibase/uniconnect.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('unidrive/collaboration.providers') {
					git url: 'git@code.bizgaze.com:unidrive/collaboration.git', credentialsId: 'jenkins_ssh_key'
				}
				dir('sprl') {
					git url: 'git@code.bizgaze.com:sprl/sprl.git', credentialsId: 'jenkins_ssh_key'
				}
				
                sh 'dotnet restore ${WORKSPACE}/bizgaze/Bizgaze.Web.Server.publish.sln'
            }
        }
		
		stage('Clean') {
		    steps {
				sh 'dotnet clean ${WORKSPACE}/bizgaze/Bizgaze.Web.Server.publish.sln --configuration Release'
			}
		}
        stage('Build') {
		    steps {
				sh 'dotnet build ${WORKSPACE}/bizgaze/Bizgaze.Web.Server.publish.sln --configuration Release --no-restore'
			}
        }/*
        stage('Test') {
            steps {
			   sh 'dotnet test ${WORKSPACE}/bizgaze/Bizgaze.Web.Server.publish.sln --no-restore'
            }
        }*/
        stage('Publish') {
			steps {
				sh 'dotnet publish ${WORKSPACE}/bizgaze/Bizgaze.Web.Server.publish.sln -o out --configuration Release --no-restore'
			}
            
        }
        stage ('Deploy') {
            steps {
				sh 'sudo ~/scripts/v3_deploy ${WORKSPACE}/out'
			}
        }
    }
	post{
		success{
			emailext body: "${currentBuild.currentResult}: Job   ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}",
			recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
			subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}"
		}/*
		always {
            deleteDir()
        }
		cleanup {
            cleanWs()
        }*/
	}
}
