pipeline {
    agent any
    stages {
		stage('Restore packages') {
            steps {
                sh 'dotnet restore ${WORKSPACE}/RazorApp.csproj'
            }
        }
		stage('Clean') {
		    steps {
			    sh 'dotnet clean ${WORKSPACE}/RazorApp.csproj --configuration Release'
			}
		}
        stage('Build') {
		    steps {
			    sh 'dotnet build ${WORKSPACE}/RazorApp.csproj --configuration Release --no-restore'
			}
        }
        /*stage('Test') {
            steps {
			   sh 'dotnet test ${WORKSPACE}/RazorApp.csproj --no-restore'
            }
        }*/
        stage('Publish') {
			steps {
				sh 'dotnet publish ${WORKSPACE} -o out --configuration Release --no-restore'
			}
            
        }
        stage ('Deploy') {
            steps {				
				sh 'sudo ~/scripts/qa_deploy ${WORKSPACE}/out'
				sh '~/scripts/push.sh ${WORKSPACE}/out'
				sh 'echo ${WORKSPACE}'
			}
        }
    }
	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()
        }
	}
}
