Jenkinsfile2 20.1 KB
Newer Older
L
liuyq-617 已提交
1 2 3
import hudson.model.Result
import hudson.model.*;
import jenkins.model.CauseOfInterruption
4
docs_only=0
L
liuyq-617 已提交
5 6 7 8
node {
}

def abortPreviousBuilds() {
T
tangfangzhi 已提交
9 10 11 12
    def currentJobName = env.JOB_NAME
    def currentBuildNumber = env.BUILD_NUMBER.toInteger()
    def jobs = Jenkins.instance.getItemByFullName(currentJobName)
    def builds = jobs.getBuilds()
L
liuyq-617 已提交
13

T
tangfangzhi 已提交
14 15 16 17
    for (build in builds) {
        if (!build.isBuilding()) {
            continue;
        }
L
liuyq-617 已提交
18

T
tangfangzhi 已提交
19 20 21
        if (currentBuildNumber == build.getNumber().toInteger()) {
            continue;
        }
L
liuyq-617 已提交
22

T
tangfangzhi 已提交
23 24
        build.doKill()    //doTerm(),doKill(),doTerm()
    }
L
liuyq-617 已提交
25 26 27 28
}
//  abort previous build
abortPreviousBuilds()
def abort_previous(){
T
tangfangzhi 已提交
29 30 31
    def buildNumber = env.BUILD_NUMBER as int
    if (buildNumber > 1) milestone(buildNumber - 1)
    milestone(buildNumber)
L
liuyq-617 已提交
32
}
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
def check_docs() {
    if (env.CHANGE_URL =~ /\/TDengine\//) {
        sh '''
            hostname
            date
            env
        '''
        sh '''
            cd ${WKC}
            git reset --hard
            git clean -fxd
            rm -rf examples/rust/
            git remote prune origin
            git fetch
        '''
        script {
            sh '''
                cd ${WKC}
                git checkout ''' + env.CHANGE_TARGET + '''
            '''
        }
        sh '''
            cd ${WKC}
56
            git remote prune origin
57 58 59 60 61 62 63
            git pull >/dev/null
            git fetch origin +refs/pull/${CHANGE_ID}/merge
            git checkout -qf FETCH_HEAD
        '''
        def file_changed = sh (
            script: '''
                cd ${WKC}
64
                git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD ${CHANGE_TARGET}`|grep -v "^docs/en/"|grep -v "^docs/zh/" || :
65 66 67 68 69 70 71 72 73 74 75
            ''',
            returnStdout: true
        ).trim()
        if (file_changed == '') {
            echo "docs PR"
            docs_only=1
        } else {
            echo file_changed
        }
    }
}
L
liuyq-617 已提交
76
def pre_test(){
77 78 79
    sh '''
        hostname
        date
80
        env
81 82 83 84
    '''
    sh '''
        cd ${WK}
        git reset --hard
85 86
        git remote prune origin
        git fetch
87 88
        cd ${WKC}
        git reset --hard
89
        git clean -fxd
H
Hui Li 已提交
90
        rm -rf examples/rust/
91 92
        git remote prune origin
        git fetch
93
    '''
L
liuyq-617 已提交
94
    script {
95 96 97 98 99 100
        sh '''
            cd ${WK}
            git checkout ''' + env.CHANGE_TARGET + '''
            cd ${WKC}
            git checkout ''' + env.CHANGE_TARGET + '''
        '''
T
tangfangzhi 已提交
101
    }
T
tangfangzhi 已提交
102 103 104
    if (env.CHANGE_URL =~ /\/TDengine\//) {
        sh '''
            cd ${WKC}
T
tangfangzhi 已提交
105
            git remote prune origin
T
tangfangzhi 已提交
106
            git pull >/dev/null
107
            git log -5
108
            echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
109
            echo "CHANGE_BRANCH:${CHANGE_BRANCH}" >>${WKDIR}/jenkins.log
110
            echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
111 112
            git fetch origin +refs/pull/${CHANGE_ID}/merge
            git checkout -qf FETCH_HEAD
113
            git log -5
114
            echo "community log merged: `git log -5`" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
115 116
            cd ${WK}
            git pull >/dev/null
117
            git log -5
118
            echo "tdinternal log: `git log -5`" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
119 120 121 122 123
        '''
    } else if (env.CHANGE_URL =~ /\/TDinternal\//) {
        sh '''
            cd ${WK}
            git pull >/dev/null
124
            git log -5
125
            echo "`date "+%Y%m%d-%H%M%S"` ${JOB_NAME}:${BRANCH_NAME}:${BUILD_ID}:${CHANGE_TARGET}" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
126
            echo "CHANGE_BRANCH:${CHANGE_BRANCH}" >>${WKDIR}/jenkins.log
127
            echo "tdinternal log: `git log -5`" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
128 129
            git fetch origin +refs/pull/${CHANGE_ID}/merge
            git checkout -qf FETCH_HEAD
130
            git log -5
131
            echo "tdinternal log merged: `git log -5`" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
132
            cd ${WKC}
T
tangfangzhi 已提交
133
            git remote prune origin
T
tangfangzhi 已提交
134
            git pull >/dev/null
135
            git log -5
136
            echo "community log: `git log -5`" >>${WKDIR}/jenkins.log
T
tangfangzhi 已提交
137 138 139 140 141 142
        '''
    } else {
        sh '''
            echo "unmatched reposiotry ${CHANGE_URL}"
        '''
    }
sangshuduo's avatar
sangshuduo 已提交
143 144 145 146 147
    sh '''
        cd ${WKC}
        git rm --cached tools/taos-tools 2>/dev/null || :
        git rm --cached tools/taosadapter 2>/dev/null || :
        git rm --cached tools/taosws-rs 2>/dev/null || :
wafwerar's avatar
wafwerar 已提交
148
        git rm --cached examples/rust 2>/dev/null || :
sangshuduo's avatar
sangshuduo 已提交
149
    '''
T
tangfangzhi 已提交
150
    sh '''
L
liuyq-617 已提交
151
        cd ${WKC}
T
tangfangzhi 已提交
152 153 154 155 156 157
        git submodule update --init --recursive
    '''
    sh '''
        cd ${WKPY}
        git reset --hard
        git pull
158
        git log -5
159 160
        echo "python connector log: `git log -5`" >>${WKDIR}/jenkins.log
        echo >>${WKDIR}/jenkins.log
L
liuyq-617 已提交
161
    '''
T
tangfangzhi 已提交
162 163
    return 1
}
T
tangfangzhi 已提交
164 165 166 167 168 169 170 171 172 173 174 175
def pre_test_build_mac() {
    sh '''
        hostname
        date
    '''
    sh '''
        cd ${WK}
        rm -rf debug
        mkdir debug
    '''
    sh '''
        cd ${WK}/debug
haoranc's avatar
haoranc 已提交
176
        cmake .. -DBUILD_TEST=true -DBUILD_HTTPS=false  -DCMAKE_BUILD_TYPE=Release
177
        make -j10
haoranc's avatar
haoranc 已提交
178
        ctest -j10 || exit 7
T
tangfangzhi 已提交
179 180 181 182 183
    '''
    sh '''
        date
    '''
}
T
tangfangzhi 已提交
184 185 186
def pre_test_win(){
    bat '''
        hostname
187 188 189
        taskkill /f /t /im python.exe
        taskkill /f /t /im bash.exe
        taskkill /f /t /im taosd.exe
T
tangfangzhi 已提交
190 191
        ipconfig
        set
T
tangfangzhi 已提交
192 193
        date /t
        time /t
T
tangfangzhi 已提交
194
        rd /s /Q %WIN_INTERNAL_ROOT%\\debug || exit 0
T
tangfangzhi 已提交
195 196
    '''
    bat '''
T
tangfangzhi 已提交
197
        cd %WIN_INTERNAL_ROOT%
198
        git reset --hard
199 200
        git remote prune origin
        git fetch
T
tangfangzhi 已提交
201 202
    '''
    bat '''
T
tangfangzhi 已提交
203
        cd %WIN_COMMUNITY_ROOT%
204
        git clean -fxd
T
tangfangzhi 已提交
205
        git reset --hard
206 207
        git remote prune origin
        git fetch
T
tangfangzhi 已提交
208 209
    '''
    script {
210 211 212 213 214 215 216 217
        bat '''
            cd %WIN_INTERNAL_ROOT%
            git checkout ''' + env.CHANGE_TARGET + '''
        '''
        bat '''
            cd %WIN_COMMUNITY_ROOT%
            git checkout ''' + env.CHANGE_TARGET + '''
        '''
T
tangfangzhi 已提交
218
    }
219 220 221
    script {
        if (env.CHANGE_URL =~ /\/TDengine\//) {
            bat '''
T
tangfangzhi 已提交
222
                cd %WIN_INTERNAL_ROOT%
haoranc's avatar
haoranc 已提交
223
                git pull origin ''' + env.CHANGE_TARGET + '''
T
tangfangzhi 已提交
224 225
            '''
            bat '''
T
tangfangzhi 已提交
226 227
                cd %WIN_COMMUNITY_ROOT%
                git remote prune origin
haoranc's avatar
haoranc 已提交
228
                git pull  origin ''' + env.CHANGE_TARGET + '''
T
tangfangzhi 已提交
229 230
            '''
            bat '''
T
tangfangzhi 已提交
231
                cd %WIN_COMMUNITY_ROOT%
T
tangfangzhi 已提交
232 233 234
                git fetch origin +refs/pull/%CHANGE_ID%/merge
            '''
            bat '''
T
tangfangzhi 已提交
235
                cd %WIN_COMMUNITY_ROOT%
236 237 238 239
                git checkout -qf FETCH_HEAD
            '''
        } else if (env.CHANGE_URL =~ /\/TDinternal\//) {
            bat '''
T
tangfangzhi 已提交
240
                cd %WIN_INTERNAL_ROOT%
haoranc's avatar
haoranc 已提交
241
                git pull origin ''' + env.CHANGE_TARGET + '''
T
tangfangzhi 已提交
242 243
            '''
            bat '''
T
tangfangzhi 已提交
244
                cd %WIN_INTERNAL_ROOT%
T
tangfangzhi 已提交
245 246 247
                git fetch origin +refs/pull/%CHANGE_ID%/merge
            '''
            bat '''
T
tangfangzhi 已提交
248
                cd %WIN_INTERNAL_ROOT%
249
                git checkout -qf FETCH_HEAD
T
tangfangzhi 已提交
250 251
            '''
            bat '''
T
tangfangzhi 已提交
252 253
                cd %WIN_COMMUNITY_ROOT%
                git remote prune origin
254 255 256
                git pull
            '''
        } else {
T
tangfangzhi 已提交
257 258
            bat '''
                echo "unmatched reposiotry %CHANGE_URL%"
259 260 261
            '''
        }
    }
T
tangfangzhi 已提交
262
    bat '''
T
tangfangzhi 已提交
263
        cd %WIN_INTERNAL_ROOT%
T
tangfangzhi 已提交
264
        git branch
T
tangfangzhi 已提交
265 266 267
        git log -5
    '''
    bat '''
T
tangfangzhi 已提交
268
        cd %WIN_COMMUNITY_ROOT%
T
tangfangzhi 已提交
269
        git branch
T
tangfangzhi 已提交
270 271
        git log -5
    '''
sangshuduo's avatar
sangshuduo 已提交
272 273 274 275 276
    bat '''
        cd %WIN_COMMUNITY_ROOT%
        git rm --cached tools/taos-tools 2>nul
        git rm --cached tools/taosadapter 2>nul
        git rm --cached tools/taosws-rs 2>nul
wafwerar's avatar
wafwerar 已提交
277
        git rm --cached examples/rust 2>nul
sangshuduo's avatar
sangshuduo 已提交
278 279
        exit 0
    '''
T
tangfangzhi 已提交
280
    bat '''
T
tangfangzhi 已提交
281
        cd %WIN_COMMUNITY_ROOT%
282
        git submodule update --init --recursive
T
tangfangzhi 已提交
283
    '''
284
    bat '''
T
tangfangzhi 已提交
285
        cd %WIN_CONNECTOR_ROOT%
286 287 288 289 290
        git branch
        git reset --hard
        git pull
    '''
    bat '''
T
tangfangzhi 已提交
291
        cd %WIN_CONNECTOR_ROOT%
292 293
        git log -5
    '''
T
tangfangzhi 已提交
294 295 296 297 298
}
def pre_test_build_win() {
    bat '''
        echo "building ..."
        time /t
T
tangfangzhi 已提交
299
        cd %WIN_INTERNAL_ROOT%
T
tangfangzhi 已提交
300 301
        mkdir debug
        cd debug
T
tangfangzhi 已提交
302
        time /t
T
tangfangzhi 已提交
303 304
        call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
        set CL=/MP8
T
tangfangzhi 已提交
305 306
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> cmake"
        time /t
307
        cmake .. -G "NMake Makefiles JOM" -DBUILD_TEST=true -DBUILD_TOOLS=true || exit 7
T
tangfangzhi 已提交
308
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> jom -j 6"
309
        time /t
T
tangfangzhi 已提交
310
        jom -j 6 || exit 8
T
tangfangzhi 已提交
311
        time /t
T
tangfangzhi 已提交
312
    '''
313
    bat '''
T
tangfangzhi 已提交
314
        cd %WIN_CONNECTOR_ROOT%
315
        python.exe -m pip install --upgrade pip
316
        python -m pip install .
T
tangfangzhi 已提交
317
        xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
318
    '''
L
liuyq-617 已提交
319 320
    return 1
}
T
tangfangzhi 已提交
321
def run_win_ctest() {
T
tangfangzhi 已提交
322 323 324
    bat '''
        echo "windows ctest ..."
        time /t
T
tangfangzhi 已提交
325
        cd %WIN_INTERNAL_ROOT%\\debug
T
tangfangzhi 已提交
326
        ctest -j 1 || exit 7
T
tangfangzhi 已提交
327 328 329
        time /t
    '''
}
T
tangfangzhi 已提交
330 331 332
def run_win_test() {
    bat '''
        echo "windows test ..."
T
tangfangzhi 已提交
333
        cd %WIN_CONNECTOR_ROOT%
334
        python.exe -m pip install --upgrade pip
T
tangfangzhi 已提交
335
        python -m pip install .
T
tangfangzhi 已提交
336
        xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32
T
tangfangzhi 已提交
337
        ls -l C:\\Windows\\System32\\taos.dll
T
tangfangzhi 已提交
338
        time /t
T
tangfangzhi 已提交
339
        cd %WIN_SYSTEM_TEST_ROOT%
T
tangfangzhi 已提交
340
        echo "testing ..."
341
        test-all.bat ci
T
tangfangzhi 已提交
342 343 344
        time /t
    '''
}
L
liuyq-617 已提交
345 346

pipeline {
T
tangfangzhi 已提交
347 348 349
    agent none
    options { skipDefaultCheckout() } 
    environment{
T
tangfangzhi 已提交
350
        WKDIR = '/var/lib/jenkins/workspace'
T
tangfangzhi 已提交
351
        WK = '/var/lib/jenkins/workspace/TDinternal'
T
tangfangzhi 已提交
352 353
        WKC = '/var/lib/jenkins/workspace/TDinternal/community'
        WKPY = '/var/lib/jenkins/workspace/taos-connector-python'
T
tangfangzhi 已提交
354 355
    }
    stages {
356 357 358 359 360 361 362 363 364
        stage('check') {
            when {
                allOf {
                    not { expression { env.CHANGE_BRANCH =~ /docs\// }}
                    not { expression { env.CHANGE_URL =~ /\/TDinternal\// }}
                }
            }
            parallel {
                stage('check docs') {
haoranc's avatar
haoranc 已提交
365
                    agent{label " slave1_47 || slave1_48 || slave1_49 || slave1_52 || worker03 || slave215 || slave217 || slave219 || Mac_catalina "}
T
tangfangzhi 已提交
366 367 368
                    steps {
                        check_docs()
                    }
369 370 371
                }
            }
        }
T
tangfangzhi 已提交
372
        stage('run test') {
T
tangfangzhi 已提交
373 374 375
            when {
                allOf {
                    not { expression { env.CHANGE_BRANCH =~ /docs\// }}
376
                    expression { docs_only == 0 }
T
tangfangzhi 已提交
377 378
                }
            }
T
tangfangzhi 已提交
379
            parallel {
T
tangfangzhi 已提交
380 381
                stage('windows test') {
                    agent{label " windows10_01 || windows10_02 || windows10_03 || windows10_04 "}
T
tangfangzhi 已提交
382 383 384 385 386 387
                    environment{
                        WIN_INTERNAL_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal"
                        WIN_COMMUNITY_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community"
                        WIN_SYSTEM_TEST_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community\\tests\\system-test"
                        WIN_CONNECTOR_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\taos-connector-python"
                    }
T
tangfangzhi 已提交
388
                    steps {
T
tangfangzhi 已提交
389
                        catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
T
tangfangzhi 已提交
390
                            timeout(time: 55, unit: 'MINUTES'){
T
tangfangzhi 已提交
391 392 393 394 395 396
                                pre_test_win()
                                pre_test_build_win()
                                run_win_ctest()
                                run_win_test()
                            }
                        }
T
tangfangzhi 已提交
397 398
                    }
                }
T
tangfangzhi 已提交
399 400 401 402 403 404 405 406 407 408 409
                stage('mac test') {
                    agent{label " Mac_catalina "}
                    steps {
                        catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
                            timeout(time: 20, unit: 'MINUTES'){
                                pre_test()
                                pre_test_build_mac()
                            }
                        }
                    }
                }
T
tangfangzhi 已提交
410
                stage('linux test') {
haoranc's avatar
haoranc 已提交
411
                    agent{label " slave1_47 || slave1_48 || slave1_49 || slave1_52 || worker03 || slave215 || slave217 || slave219 "}
T
tangfangzhi 已提交
412 413 414 415 416
                    options { skipDefaultCheckout() } 
                    when {
                        changeRequest()
                    }
                    steps {
417 418 419 420 421 422 423 424
                        script {
                            def linux_node_ip = sh (
                                script: 'ip addr|grep 192|grep -v virbr|awk "{print \\\$2}"|sed "s/\\/.*//"',
                                returnStdout: true
                            ).trim()
                            echo "${linux_node_ip}"
                            echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}"
                        }
T
tangfangzhi 已提交
425
                        catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
426
                            timeout(time: 120, unit: 'MINUTES'){
427
                                pre_test()
T
tangfangzhi 已提交
428 429 430 431
                                script {
                                    sh '''
                                        date
                                        rm -rf ${WKC}/debug
432
                                        cd ${WKC}/tests/parallel_test
433
                                        time ./container_build.sh -w ${WKDIR} -t 10 -e
T
tangfangzhi 已提交
434
                                    '''
T
tangfangzhi 已提交
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
                                    def extra_param = ""
                                    def log_server_file = "/home/log_server.json"
                                    def timeout_cmd = ""
                                    if (fileExists(log_server_file)) {
                                        def log_server_enabled = sh (
                                            script: 'jq .enabled ' + log_server_file,
                                            returnStdout: true
                                        ).trim()
                                        def timeout_param = sh (
                                            script: 'jq .timeout ' + log_server_file,
                                            returnStdout: true
                                        ).trim()
                                        if (timeout_param != "null" &&  timeout_param != "0") {
                                            timeout_cmd = "timeout " + timeout_param
                                        }
                                        if (log_server_enabled == "1") {
                                            def log_server = sh (
                                                script: 'jq .server ' + log_server_file + ' | sed "s/\\\"//g"',
                                                returnStdout: true
                                            ).trim()
                                            if (log_server != "null" && log_server != "") { 
                                                extra_param = "-w " + log_server
                                            }
                                        }
                                    }
T
tangfangzhi 已提交
460 461 462 463
                                    sh '''
                                        cd ${WKC}/tests/parallel_test
                                        export DEFAULT_RETRY_TIME=2
                                        date
464
                                        ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 ''' + extra_param + '''
T
tangfangzhi 已提交
465 466 467 468
                                    '''
                                }
                            }
                        }
T
tangfangzhi 已提交
469
                        /*catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
T
tangfangzhi 已提交
470
                            timeout(time: 15, unit: 'MINUTES'){
T
tangfangzhi 已提交
471 472 473 474
                                script {
                                    sh '''
                                        echo "packaging ..."
                                        date
475
                                        rm -rf ${WKC}/release/*
T
tangfangzhi 已提交
476 477
                                        cd ${WKC}/packaging
                                        ./release.sh -v cluster -n 3.0.0.100 -s static
T
tangfangzhi 已提交
478
                                    '''
479 480
                                }
                            }
T
tangfangzhi 已提交
481
                        }*/
T
tangfangzhi 已提交
482 483
                    }
                }
L
liuyq-617 已提交
484
            }
T
tangfangzhi 已提交
485 486 487
        }
    }
    post {  
L
liuyq-617 已提交
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
        success {
            emailext (
                subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' SUCCESS",
                body: """<!DOCTYPE html>
                <html>
                <head>
                <meta charset="UTF-8">
                </head>
                <body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
                    <table width="95%" cellpadding="0" cellspacing="0" style="font-size: 16pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
                        <tr>
                            <td><br />
                                <b><font color="#0B610B"><font size="6">构建信息</font></font></b>
                                <hr size="2" width="100%" align="center" /></td>
                        </tr>
                        <tr>
                            <td>
                                <ul>
                                <div style="font-size:18px">
                                    <li>构建名称>>分支:${env.BRANCH_NAME}</li>
                                    <li>构建结果:<span style="color:green"> Successful </span></li>
                                    <li>构建编号:${BUILD_NUMBER}</li>
                                    <li>触发用户:${env.CHANGE_AUTHOR}</li>
                                    <li>提交信息:${env.CHANGE_TITLE}</li>
                                    <li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
                                    <li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
                                    
                                </div>
                                </ul>
                            </td>
                        </tr>
                    </table></font>
                </body>
                </html>""",
                to: "${env.CHANGE_AUTHOR_EMAIL}",
                from: "support@taosdata.com"
            )
        }
        failure {
            emailext (
                subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' FAIL",
                body: """<!DOCTYPE html>
                <html>
                <head>
                <meta charset="UTF-8">
                </head>
                <body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
                    <table width="95%" cellpadding="0" cellspacing="0" style="font-size: 16pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
                        <tr>
                            <td><br />
                                <b><font color="#0B610B"><font size="6">构建信息</font></font></b>
                                <hr size="2" width="100%" align="center" /></td>
                        </tr>
                        <tr>
                            <td>
                                <ul>
                                <div style="font-size:18px">
                                    <li>构建名称>>分支:${env.BRANCH_NAME}</li>
                                    <li>构建结果:<span style="color:red"> Failure </span></li>
                                    <li>构建编号:${BUILD_NUMBER}</li>
                                    <li>触发用户:${env.CHANGE_AUTHOR}</li>
                                    <li>提交信息:${env.CHANGE_TITLE}</li>
                                    <li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
                                    <li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
                                    
                                </div>
                                </ul>
                            </td>
                        </tr>
                    </table></font>
                </body>
                </html>""",
                to: "${env.CHANGE_AUTHOR_EMAIL}",
                from: "support@taosdata.com"
            )
        }
    } 
}