link:https://my.oschina.net/powertoolsteam/blog/2354154?origin=wechat

node {
    stage('业务代码') {
        sh label: '清理工作目录',script: 'rm -rf ${WORKSPACE}/*'
         git credentialsId: 'gitlab_admin_token', url: 'http://git.vops.top/test/python_auto.git'
    }
    stage('接口测试') {
        sh label: '创建临时接口代码目录', script: 'mkdir -p ${WORKSPACE}/test_code'
        dir('${WORKSPACE}/test_code') {
            git credentialsId: 'gitlab_admin_token', url: 'http://git.vops.top/jcfc_test/postman-auto.git'
            sh label: '开始接口测试', script: 'newman run test.postman_collection.json  -n 1 -d qdatao.json -e test.postman_environment.json  -r cli,html --reporter-html-template ${JENKINS_HOME}/postman_templates/htmlreqres.hbs --reporter-html-export ./test_code/reporter/index.html'
            publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, keepAll: true, reportDir: './test_code/reporter/', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: 'report'])
        }
    }
    stage('结束') {
        def content = readFile(file: "./test_code/reporter/index.html")
        emailext attachmentsPattern: './test_code/reporter/index.html', body: content, subject: '', to: 'yankai@jcfc.cn',
        echo currentBuild.fullDisplayName
    }
}

发表评论

邮箱地址不会被公开。