问题
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