我正在使用concourse ci流水线运行一些自动化测试。我的要求是,如果任何测试失败,则将构建标记为失败,并通过电子邮件发送结果。在大厅里有办法做到这一点吗?电子邮件功能运行良好,但即使测试失败,构建也会通过。
发布于 2020-01-13 01:36:53
在假定退出代码正确的情况下,您将需要在concourse上使用on failure步骤,并将其添加到您的作业中,如下所示
jobs:
- name: myBuild
plan:
- get: your-repo
passed: []
trigger: false
- task: run-tests
file: runMyTestsTask.yml
on_failure:
- put: send-an-email
params:
subject_text: "Your email subect i.e Failed Build"
body_text: "Your message when the build has failed"
on_success:
put: push-my-build
## Define your additional resources here
resources:
- name: send-an-email
type: email
source:
smtp:
host: smtp.example.com
port: "587" # this must be a string
username: a-user
password: my-password
from: build-system@example.com
to: [ "dev-team@example.com", "product@example.net" ] #optional if `params.additional_recipient` is specified
resource_types:
- name: email
type: docker-image
source:
repository: pcfseceng/email-resource 此外,如果您需要输出一些有关构建的相关信息,您可以通过包含一些包装大厅元数据的环境变量来做到这一点,您可以将其包含在电子邮件消息的正文中,有关如何执行此操作的更多详细信息,请参阅电子邮件资源的文档:https://github.com/pivotal-cf/email-resource。
发布于 2019-12-23 19:13:03
如果你是running JMeter in command-line non-GUI mode用户,你的命令需要返回non-zero exit status code
即使测试中有失败,JMeter进程也会有0退出代码,因此任何CI系统都会将执行视为成功:

如果您正在寻找一个仅用于JMeter的解决方案,您可以将JSR223 Assertion添加到您的测试计划中,并将以下代码放入“脚本”区域:
if (!prev.isSuccessful()) {
props.put('failure', 'true')
}然后将tearDown Thread Group添加到您的测试计划中,并使用以下代码将JSR223 Sampler放入其中:
if (props.get('failure').equals('true')) {
System.exit(1)
}如果JSR223断言Scope中的任何采样器失败-整个JMeter过程将以退出代码1结束,该代码被任何上游处理系统视为错误。

另一种选择是考虑使用Taurus工具作为JMeter测试的包装器,金牛座提供了灵活的pass/fail criteria subsystem,允许您定义测试成功与否的阈值。如果超过阈值-金牛座将返回非零退出代码,这应该被大厅(或任何其他软件)“理解”。
https://stackoverflow.com/questions/59430833
复制相似问题