Jenkinsfile 1.85 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
node('local') {
2
    try {
Peter van 't Hof's avatar
Peter van 't Hof committed
3

4 5 6 7
        stage('Init') {
            tool 'JDK 8u102'
            tool 'Apache Maven 3.3.9'
        }
Peter van 't Hof's avatar
Peter van 't Hof committed
8

Peter van 't Hof's avatar
Peter van 't Hof committed
9
        timeout(45) {
10 11 12 13
            stage('Checkout') {
                checkout scm
                sh 'git submodule update --init --recursive'
            }
14
        }
Peter van 't Hof's avatar
Peter van 't Hof committed
15

16
        timeout(45) {
17 18 19 20
            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'
                }
Peter van 't Hof's avatar
Peter van 't Hof committed
21
            }
22
        }
Peter van 't Hof's avatar
Peter van 't Hof committed
23

24 25 26
        stage('Check git on changes') {
            sh 'if [ $(git diff | wc -l) -eq 0 ]; then true; else echo "[ERROR] Git is not clean anymore after build"; git diff; echo "[ERROR] This might be caused by reformated code, if so run maven locally"; false; fi'
        }
akaljuvee's avatar
akaljuvee committed
27

28 29 30
        stage('Check Documentation') {
            sh 'mkdocs build --clean --strict'
        }
Peter van 't Hof's avatar
Peter van 't Hof committed
31

32
        if (currentBuild.result == null || "SUCCESS" == currentBuild.result) {
33 34 35 36 37
            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')
        }
Peter van 't Hof's avatar
Peter van 't Hof committed
38

39
    } catch (e) {
40
        if (currentBuild.result == null || "FAILED" == currentBuild.result) {
41
            currentBuild.result = "FAILED"
42
        }
43 44 45
        slackSend(color: '#FF0000', message: "${currentBuild.result}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}' (<${env.BUILD_URL}|Open>)", channel: '#biopet-bot', teamDomain: 'lumc', tokenCredentialId: 'lumc')

        throw e
Peter van 't Hof's avatar
Peter van 't Hof committed
46 47
    }
}