Jenkinsfile 1.64 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
node('local') {
    properties([[$class: 'GitLabConnectionProperty', gitLabConnection: 'https://git.lumc.nl/'], pipelineTriggers([[$class: 'GitHubPushTrigger']])])

    try {

        stage('Init') {
            tool 'JDK 8u102'
            tool 'Apache Maven 3.3.9'
        }

        stage('Checkout') {
            checkout scm
            sh 'git submodule update --init --recursive'
        }

        stage('Build and Test') {
            withMaven(maven: 'Apache Maven 3.3.9', jdk: 'JDK 8u102') {
                sh 'mvn -B -T 2 -Dmaven.test.failure.ignore clean package'
            }
        }

        stage('Report tests') {
Peter van 't Hof's avatar
Peter van 't Hof committed
23
            junit '*/target/surefire-reports/*.xml'
Peter van 't Hof's avatar
Peter van 't Hof committed
24 25
        }

Peter van 't Hof's avatar
Peter van 't Hof committed
26
        if(currentBuild.result == null || "SUCCESS".equals(currentBuild.result)) {
Peter van 't Hof's avatar
Peter van 't Hof committed
27 28 29 30 31 32 33
            currentBuild.result = "SUCCESS"
            slackSend (color: '#00FF00', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
        } else {
            slackSend (color: '#FFFF00', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
        }

    } catch (e) {
Peter van 't Hof's avatar
Peter van 't Hof committed
34
        if(currentBuild.result = null || "FAILED".equals(currentBuild.result)) {
35 36 37
            currentBuild.result = "FAILED"
        }
        slackSend (color: '#FF0000', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')
Peter van 't Hof's avatar
Peter van 't Hof committed
38 39 40 41

        throw e
    }
}