Is there a way I could report back my robot tests results from Jenkins to slack?

[亡魂溺海] 提交于 2020-03-25 19:22:06

问题


I have tests that run on Jenkins. - Robot Framework Tests. They run on a scheduled basis, but no one really takes a look.

I wanted to see if there is a mechanism using which, I could report back the results to a slack channel once the job completes executing tests.


def branch = "branchName"

node ('AWS-LoadTest') { 
    stage ('Checkout') {
        cleanWs()
        checkout([$class: 'GitSCM', branches: [[name: branch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '9999999-99999999', url: 'git@github.com:Abcd/abc.git']]]) 
    }
    stage ('Execute Tests'){ 
        def colorCode = '#FF0000'
        def buildStatus = 'FAILURE'
        String slackChannel='#slackChannelName'
        try {
            bat """  
            robot -d outputs --variable ENV:prod -i production TestAutomation/RobotTests/testsuites/test.robot
            """
            buildStatus = 'SUCCESS'
            colorCode = '#00FF00'
        } catch (e) {
            colorCode = '#FF0000'
            def summary = "${buildStatus}: Production Health Check Test, ${env.BUILD_URL}",
            slackSend(channel: slackChannel, color: 'danger', message: """)
            }

         finally {
            step([
            $class : 'RobotPublisher',
            outputPath : 'outputs/',
            outputFileName : "*.xml",
            disableArchiveOutput : false,
            passThreshold : 100,
            unstableThreshold: 80.0,
            otherFiles : "*.png" ])    
        }   
    }
}

来源:https://stackoverflow.com/questions/60158611/is-there-a-way-i-could-report-back-my-robot-tests-results-from-jenkins-to-slack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!