flying3615
2/20/2017 - 8:43 AM

JenkinsFile.groovy

JenkinsFile.groovy

node {
    try{
    stage 'checkout'
    git 'https://github.com/g0t4/jenkins2-course-spring-boot.git'
    def project_path = "spring-boot-samples/spring-boot-sample-atmosphere"
    
    dir(project_path) {
        stage 'compiling, test, packaging'
        sh '/var/jenkins_home/apache-maven-3.3.9/bin/mvn clean package'
        
        stage 'archival'
        publishHTML([allowMissing: true, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'target/site/jacoco/', reportFiles: 'index.html', reportName: 'Code Coverage'])
        junit 'target/surefire-reports/*.xml'
        archiveArtifacts "target/*.jar"
    }
    stage 'send mail when success'
     mail bcc: '', body: "${JOB_NAME} [${BUILD_NUMBER}] is success", cc: '', from: '', replyTo: '', subject: 'test jenkins', to: 'flying3615@163.com'
    }catch(err){
        stage 'send mail when failed'
         mail bcc: '', body: "${err} is failed", cc: '', from: '', replyTo: '', subject: 'test jenkins', to: 'flying3615@163.com'
    }
   
}