Jenkins代码详见:
https://gitee.com/roclli/7-parameters-script.git
Jenkinsfile内容为:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                checkout scm    //此处实际上执行了两次,第一次是界面指定了scm,本次又执行了一次
                echo '---going to execute---'
                sh 'mvn verify'
            }
        }
    }
    post {
        always {
            echo '---going to catch report---'
            junit '**/target/surefire-reports/TEST-**.xml'
        }
        failure {
            echo '---send mail start---'
//          mail to: 'lijun11@metersbonwe.com', subject: 'The Pipeline(handing failure) failed :(', body: 'this is body'
//            mail to: 'devops@acme.com', subject: "Job '${JOB_NAME}' (${BUILD_NUMBER}) is waiting for input",
//    body: "Please go to ${BUILD_URL} and verify the build"
//            step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "lijun11@metersbonwe.com", sendToIndividuals: true])
            emailext body: 'this is body', subject: 'The Pipeline(handing failure) failed :(', to: 'lijun11@metersbonwe.com'
            echo '---send mail done---'
        }
    }
}