【问题标题】:How to output test pass/failure notification to slack through Jenkins when running pabot运行pabot时如何通过Jenkins向slack输出测试通过/失败通知
【发布时间】:2019-07-12 02:06:00
【问题描述】:

我想通过 Jenkins 使用 pabot(机器人框架测试的并行运行)在 slack 中设置通知。

我已经将 Jenkins 配置为在使用机器人时输出通过/失败/跳过通知,但是一旦我将其更改为 pabot,通知就不再出现在我的 slack 频道中。

此命令运行成功,我的 slack 频道收到了测试通知 通过/失败/跳过

robot -A Config/Config.args -d results -v REMOTE_URL:http://dummy:0000/wd/hub Tests

另一方面,这个命令会提醒我的频道构建已经开始,但之后什么都没有

pabot -A Config/Config.args -d results -v REMOTE_URL:http://dummy:0000/wd/hub Tests

在该目录中,将创建一个 pabot_results 文件,该文件与使用机器人命令的构建不同。但是 output.xml、log.html 和 report.html 文件包含了预期的结果。

我希望基本通过/失败/跳过出现在松弛通道中以进行并行运行测试。目前,slack 频道中没有出现任何测试结果。

【问题讨论】:

    标签: jenkins robotframework slack


    【解决方案1】:

    我正在使用Jenkins declarative pipeline,并且在使用Token Macro plugin 运行机器人测试后,我已经解决了帖子部分中的问题:

    post {
        always {
            robot(
                outputPath: 'Reports/',
                outputFileName: 'output.xml',
                reportFileName: 'report.html',
                logFileName: 'log.html',
                disableArchiveOutput: false,
                passThreshold: 100.0,
                unstableThreshold: 95.0,
                otherFiles: '*.png,debug.log'
            )
            script {
                String robotReportSummary = tm('ROBOT_FAILEDCASES: ${ROBOT_FAILEDCASES}, ROBOT_PASSPERCENTAGE: ${ROBOT_PASSPERCENTAGE}, ROBOT_PASSRATIO: ${ROBOT_PASSRATIO}, ROBOT_REPORTLINK: ${ROBOT_REPORTLINK}')
                // Instead of echo step you can use whatever you want with variable robotReportSummary
                echo "${robotReportSummary}"
            }
        }
    }
    

    更多信息:

    Robot Framework plugin 的文档中可以看到以下令牌宏的插件导出:

    • ${ROBOT_FAILEDCASES}
    • ${ROBOT_PASSPERCENTAGE, onlyCritical}
    • ${ROBOT_PASSRATIO, onlyCritical}
    • ${ROBOT_REPORTLINK}

    也可以从source code of Robot Framework plugin 找到其他未记录的令牌宏:

    • ${ROBOT_FAILED}
    • ${ROBOT_PASSED}
    • ${ROBOT_TOTAL}

    为了在声明式管道中访问这些宏,您可以使用Token Macro plugin,它是管道步骤tm。从文档中不清楚它是否返回带有替换变量的字符串。但是可以找到用法,例如here 在令牌宏插件的源代码中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-07
      • 1970-01-01
      • 2015-10-05
      • 1970-01-01
      • 2012-07-22
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      相关资源
      最近更新 更多