This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Jenkinsfile 1.68 KiB
Newer Older
pipeline {
  agent any
  environment { 
        scannerHome = tool 'SonarQube Scanner'
    }
   options {
Michael Breu's avatar
Michael Breu committed
       buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
   }
   tools {
        // Install the Maven version configured as "M3" and add it to the path.
        maven "/usr/share/maven"
Michael Breu's avatar
Michael Breu committed
        jdk "java-11"
        nodejs "Node15.11"
Michael Breu's avatar
Michael Breu committed
    stage('Compile and Test') {
Michael Breu's avatar
Michael Breu committed
      steps {
		milestone 1
                withSonarQubeEnv('SonarQube Production') {
                    sh "mvn -Dmaven.test.failure.ignore=true  clean test"
                }
      }
    }
    stage('Evaluate') {
      steps {
Michael Breu's avatar
Michael Breu committed
		milestone 2
			  junit(testResults: 'target/test-results/test/**/*.xml', healthScaleFactor: 100)
	  		  jacoco(execPattern: 'target/jacoco/test.exec',  sourcePattern: 'src/main/java', sourceInclusionPattern: '**/*.java')
		      sh "npm test"
              sh "mvn jacoco:report"
    stage('SonarAnalysis') {
      steps {
        milestone 3
            def scannerHome = tool 'SonarQube Scanner';
             withSonarQubeEnv('SonarQube Production') { 
                 sh "${scannerHome}/bin/sonar-scanner"
             }                
           }
       }
Michael Breu's avatar
Michael Breu committed
   }

  post {
		failure {
		   notifyByEmail("Failure");
		}
		unstable  {
		   notifyByEmail("Unstable");
		}
		fixed {
		   notifyByEmail("Fixed");
		}
	}
	
}

	void notifyByEmail(String reason) {
		def mailRecipients = "michael.breu@arctis.at"
	  emailext (
		  subject: reason + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
		  body: '''${SCRIPT, template="groovy-html.template"}''',
		  mimeType: 'text/html',
		  recipientProviders: [[$class: 'CulpritsRecipientProvider']]
		)
	
    }