xref: /aosp_15_r20/external/apache-commons-lang/Jenkinsfile (revision 455610af95f3bf5f4bc8a9eda520f57e389a4c42)
1*455610afSAndroid Build Coastguard Worker#!groovy
2*455610afSAndroid Build Coastguard Worker
3*455610afSAndroid Build Coastguard Worker/*
4*455610afSAndroid Build Coastguard Worker *
5*455610afSAndroid Build Coastguard Worker *  Licensed to the Apache Software Foundation (ASF) under one or more
6*455610afSAndroid Build Coastguard Worker *  contributor license agreements.  See the NOTICE file distributed with
7*455610afSAndroid Build Coastguard Worker *  this work for additional information regarding copyright ownership.
8*455610afSAndroid Build Coastguard Worker *  The ASF licenses this file to You under the Apache License, Version 2.0
9*455610afSAndroid Build Coastguard Worker *  (the "License"); you may not use this file except in compliance with
10*455610afSAndroid Build Coastguard Worker *  the License.  You may obtain a copy of the License at
11*455610afSAndroid Build Coastguard Worker *
12*455610afSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
13*455610afSAndroid Build Coastguard Worker *
14*455610afSAndroid Build Coastguard Worker *  Unless required by applicable law or agreed to in writing, software
15*455610afSAndroid Build Coastguard Worker *  distributed under the License is distributed on an "AS IS" BASIS,
16*455610afSAndroid Build Coastguard Worker *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17*455610afSAndroid Build Coastguard Worker *  See the License for the specific language governing permissions and
18*455610afSAndroid Build Coastguard Worker *  limitations under the License.
19*455610afSAndroid Build Coastguard Worker *
20*455610afSAndroid Build Coastguard Worker */
21*455610afSAndroid Build Coastguard Workerpipeline {
22*455610afSAndroid Build Coastguard Worker    agent {
23*455610afSAndroid Build Coastguard Worker        node {
24*455610afSAndroid Build Coastguard Worker            label 'ubuntu'
25*455610afSAndroid Build Coastguard Worker        }
26*455610afSAndroid Build Coastguard Worker    }
27*455610afSAndroid Build Coastguard Worker
28*455610afSAndroid Build Coastguard Worker    tools {
29*455610afSAndroid Build Coastguard Worker        maven 'Maven 3 (latest)'
30*455610afSAndroid Build Coastguard Worker        jdk 'JDK 1.8 (latest)'
31*455610afSAndroid Build Coastguard Worker    }
32*455610afSAndroid Build Coastguard Worker
33*455610afSAndroid Build Coastguard Worker    stages {
34*455610afSAndroid Build Coastguard Worker        stage('Build') {
35*455610afSAndroid Build Coastguard Worker            steps {
36*455610afSAndroid Build Coastguard Worker                sh 'mvn'
37*455610afSAndroid Build Coastguard Worker            }
38*455610afSAndroid Build Coastguard Worker            post {
39*455610afSAndroid Build Coastguard Worker                always {
40*455610afSAndroid Build Coastguard Worker                    junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
41*455610afSAndroid Build Coastguard Worker                }
42*455610afSAndroid Build Coastguard Worker            }
43*455610afSAndroid Build Coastguard Worker        }
44*455610afSAndroid Build Coastguard Worker        stage('Deploy') {
45*455610afSAndroid Build Coastguard Worker            when {
46*455610afSAndroid Build Coastguard Worker                branch 'master'
47*455610afSAndroid Build Coastguard Worker            }
48*455610afSAndroid Build Coastguard Worker            steps {
49*455610afSAndroid Build Coastguard Worker                sh 'mvn deploy'
50*455610afSAndroid Build Coastguard Worker            }
51*455610afSAndroid Build Coastguard Worker        }
52*455610afSAndroid Build Coastguard Worker    }
53*455610afSAndroid Build Coastguard Worker
54*455610afSAndroid Build Coastguard Worker    // Send out notifications on unsuccessful builds.
55*455610afSAndroid Build Coastguard Worker    post {
56*455610afSAndroid Build Coastguard Worker        // If this build failed, send an email to the list.
57*455610afSAndroid Build Coastguard Worker        failure {
58*455610afSAndroid Build Coastguard Worker            script {
59*455610afSAndroid Build Coastguard Worker                if(env.BRANCH_NAME == "master") {
60*455610afSAndroid Build Coastguard Worker                    def state = (currentBuild.previousBuild != null) && (currentBuild.previousBuild.result == 'FAILURE') ? "Still failing" : "Failure"
61*455610afSAndroid Build Coastguard Worker                    emailext(
62*455610afSAndroid Build Coastguard Worker                            subject: "[Lang] Change on branch \"${env.BRANCH_NAME}\": ${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - $state",
63*455610afSAndroid Build Coastguard Worker                            body: """The Apache Jenkins build system has built ${env.JOB_NAME} (build #${env.BUILD_NUMBER})
64*455610afSAndroid Build Coastguard Worker
65*455610afSAndroid Build Coastguard WorkerStatus: ${currentBuild.result}
66*455610afSAndroid Build Coastguard Worker
67*455610afSAndroid Build Coastguard WorkerCheck console output at <a href="${env.BUILD_URL}">${env.BUILD_URL}</a> to view the results.
68*455610afSAndroid Build Coastguard Worker""",
69*455610afSAndroid Build Coastguard Worker                            to: "[email protected]",
70*455610afSAndroid Build Coastguard Worker                            recipientProviders: [[$class: 'DevelopersRecipientProvider']]
71*455610afSAndroid Build Coastguard Worker                    )
72*455610afSAndroid Build Coastguard Worker                }
73*455610afSAndroid Build Coastguard Worker            }
74*455610afSAndroid Build Coastguard Worker        }
75*455610afSAndroid Build Coastguard Worker
76*455610afSAndroid Build Coastguard Worker        // If this build didn't fail, but there were failing tests, send an email to the list.
77*455610afSAndroid Build Coastguard Worker        unstable {
78*455610afSAndroid Build Coastguard Worker            script {
79*455610afSAndroid Build Coastguard Worker                if(env.BRANCH_NAME == "master") {
80*455610afSAndroid Build Coastguard Worker                    def state = (currentBuild.previousBuild != null) && (currentBuild.previousBuild.result == 'UNSTABLE') ? "Still unstable" : "Unstable"
81*455610afSAndroid Build Coastguard Worker                    emailext(
82*455610afSAndroid Build Coastguard Worker                            subject: "[Lang] Change on branch \"${env.BRANCH_NAME}\": ${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - $state",
83*455610afSAndroid Build Coastguard Worker                            body: """The Apache Jenkins build system has built ${env.JOB_NAME} (build #${env.BUILD_NUMBER})
84*455610afSAndroid Build Coastguard Worker
85*455610afSAndroid Build Coastguard WorkerStatus: ${currentBuild.result}
86*455610afSAndroid Build Coastguard Worker
87*455610afSAndroid Build Coastguard WorkerCheck console output at <a href="${env.BUILD_URL}">${env.BUILD_URL}</a> to view the results.
88*455610afSAndroid Build Coastguard Worker""",
89*455610afSAndroid Build Coastguard Worker                            to: "[email protected]",
90*455610afSAndroid Build Coastguard Worker                            recipientProviders: [[$class: 'DevelopersRecipientProvider']]
91*455610afSAndroid Build Coastguard Worker                    )
92*455610afSAndroid Build Coastguard Worker                }
93*455610afSAndroid Build Coastguard Worker            }
94*455610afSAndroid Build Coastguard Worker        }
95*455610afSAndroid Build Coastguard Worker
96*455610afSAndroid Build Coastguard Worker        // Send an email, if the last build was not successful and this one is.
97*455610afSAndroid Build Coastguard Worker        success {
98*455610afSAndroid Build Coastguard Worker            script {
99*455610afSAndroid Build Coastguard Worker                if ((env.BRANCH_NAME == "master") && (currentBuild.previousBuild != null) && (currentBuild.previousBuild.result != 'SUCCESS')) {
100*455610afSAndroid Build Coastguard Worker                    emailext (
101*455610afSAndroid Build Coastguard Worker                            subject: "[Lang] Change on branch \"${env.BRANCH_NAME}\": ${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - Back to normal",
102*455610afSAndroid Build Coastguard Worker                            body: """The Apache Jenkins build system has built ${env.JOB_NAME} (build #${env.BUILD_NUMBER})
103*455610afSAndroid Build Coastguard Worker
104*455610afSAndroid Build Coastguard WorkerStatus: ${currentBuild.result}
105*455610afSAndroid Build Coastguard Worker
106*455610afSAndroid Build Coastguard WorkerCheck console output at <a href="${env.BUILD_URL}">${env.BUILD_URL}</a> to view the results.
107*455610afSAndroid Build Coastguard Worker""",
108*455610afSAndroid Build Coastguard Worker                            to: "[email protected]",
109*455610afSAndroid Build Coastguard Worker                            recipientProviders: [[$class: 'DevelopersRecipientProvider']]
110*455610afSAndroid Build Coastguard Worker                    )
111*455610afSAndroid Build Coastguard Worker                }
112*455610afSAndroid Build Coastguard Worker            }
113*455610afSAndroid Build Coastguard Worker        }
114*455610afSAndroid Build Coastguard Worker    }
115*455610afSAndroid Build Coastguard Worker}
116