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

Skip to content
Snippets Groups Projects
Jenkinsfile 1.97 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 {
Michael Breu's avatar
Michael Breu committed
        milestone 1
Michael Breu's avatar
Michael Breu committed
                withSonarQubeEnv('SonarQube Production') {
                    sh "mvn -Dmaven.test.failure.ignore=true  clean verify"
Michael Breu's avatar
Michael Breu committed
                }
      }
    }
    stage('Evaluate') {
      steps {
Michael Breu's avatar
Michael Breu committed
        milestone 2
              junit(testResults: 'target/test-results/test/**/*.xml,target/test-results/integrationTest/**/*.xml', healthScaleFactor: 100)
              jacoco(execPattern: 'target/jacoco/test/test.exec,target/jacoco/integrationTest/integrationTest.exec',  sourcePattern: 'src/main/java', sourceInclusionPattern: '**/*.java')
Michael Breu's avatar
Michael Breu committed
              sh "npm test"
              sh "mvn jacoco:report"
    stage('SonarAnalysis') {
      steps {
        milestone 3
Michael Breu's avatar
Michael Breu committed
            
             withSonarQubeEnv('SonarQube Production') { 
Michael Breu's avatar
Michael Breu committed
                 sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=GITSEARCH$BRANCH_NAME \"-Dsonar.projectName=Sharing Plattform $BRANCH_NAME\""
Michael Breu's avatar
Michael Breu committed
   }
Michael Breu's avatar
Michael Breu committed
        failure {
           notifyByEmail("Failure");
        }
        unstable  {
           notifyByEmail("Unstable");
        }
        fixed {
           notifyByEmail("Fixed");
        }
    }
    
Michael Breu's avatar
Michael Breu committed
    void notifyByEmail(String reason) {
Michael Breu's avatar
Michael Breu committed
        def mailRecipients = "michael.breu@uibk.ac.at"
Michael Breu's avatar
Michael Breu committed
      emailext (
          subject: reason + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
          body: '''${SCRIPT, template="groovy-html.template"}''',
          mimeType: 'text/html',
          recipientProviders: [[$class: 'CulpritsRecipientProvider']]
        )
    
    }