/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

pipeline {
        agent  {
            label "c6i2xlarge"
           }

    stages {
        stage('checkout') {
            steps {
              checkout scmGit(branches: [[name: '*/main']], browser: github('https://github.com/apache/tomee'), extensions: [cleanBeforeCheckout()], userRemoteConfigs: [[url: 'https://github.com/apache/tomee']])
            }
        }
        stage('Build without tests') {
            tools {
                 maven 'maven_3_latest'
                  jdk 'jdk_17_latest'
            }
            steps {
                timeout(time: 180, unit: 'MINUTES') {
                    sh 'mvn -U --show-version clean install -DskipTests'
                }
            }
        }
        stage('Test') {
            tools {
                 maven 'maven_3_latest'
                  jdk 'jdk_17_latest'
            }
            steps {
                timeout(time: 180, unit: 'MINUTES') {
                    sh 'mvn -T 2C -U --show-version --fail-at-end clean install -Pstyle,rat -DskipTests -Dfile.encodig=UTF-8'
                }
            }
            post {
                    always {
                            timeout(time: 15, unit: 'MINUTES') {
                            junit '**/target/surefire-reports/TEST-*.xml'
                        }
                    }
                }
        }
    }
    post{
        changed{
            emailext to: "commits@tomee.apache.org",
            subject: "Jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}",
            body: "${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found here: ${env.BUILD_URL}"
        }
        success {
            build job: 'main-deploy', wait: false
            build job: 'main-build-quick', wait: false
            build job: 'main-build-full-arquillian', wait: false
            build job: 'main-build-full-examples', wait: false
            build job: 'main-build-full-itests', wait: false
            build job: 'main-build-full-tck', wait: false
        }
    }
}
