pipeline {
    agent any
    triggers {
        pollSCM 'H 5 * * *'
    }
    options {
        buildDiscarder(logRotator(numToKeepStr: '100', artifactNumToKeepStr: '1'))
        disableConcurrentBuilds()
        timestamps()
        timeout(time: 1, unit: 'HOURS')
        skipDefaultCheckout true
    }
    tools {
        jdk 'openlogic-openjdk-17.0.17+10'
    }
    stages {
        stage('checkout') {
            steps {
                checkout([$class: 'GitSCM',
                    branches: [[name: '*/master']],
                    extensions: [],
                    userRemoteConfigs: [[url: 'https://github.com/Wetator/wetator.git']]])
            }
        }
        stage('build') {
            steps {
                wrap([$class: 'Xvfb']) {
                    sh "mvn clean verify -Dgpg.skip"
                }
            }
        }
    }
    post {
        always {
            junit allowEmptyResults: true, testResults: 'target/surefire-reports/*.xml'
            recordIssues enabledForFailure: true, sourceCodeEncoding: 'UTF-8', tools: [
                checkStyle(),
                spotBugs(),
                pmdParser(),
                cpd(),
                java(),
                javaDoc(),
                taskScanner(highTags: 'FIXME, XXX', normalTags: 'TODO', includePattern: '**/*.java, **/*.xhtml, **/*.jsp, **/*.html, **/*.js, **/*.css, **/*.xml, **/*.wet, **/*.properties', excludePattern: 'test/webpage/js/**/*')]
            archiveArtifacts artifacts: 'deploy/wetator-*.zip, deploy/wetator-*.jar', allowEmptyArchive: true, fingerprint: true
            step([$class: 'Mailer',
                notifyEveryUnstableBuild: true,
                recipients: "rbri@rbri.de, frank.danek@gmail.com"])
        }
    }
}