azure-devops - 根据先前任务日志中的字符串有条件地运行 Azure DevOps 任务
问题描述
我有一个运行几个 JMeter 测试和一些 Powershell 脚本的 CI 管道。
如果 JMeter 测试失败,它仍会在 DevOps 中报告为成功。
但是,日志会显示“Err:”,然后是测试中失败的调用次数。
如果“运行出站电子邮件 JMeter 测试”任务已完成且日志中不包含“Err:”,我如何才能仅运行以下任务(写入线程引用)?
解决方案
I think the better option would be failing the whole "Run Outbound Email JMeter Test" task so if there are failures it would return non-zero exit status code so the pipeline would "catch" it
For example you can run your test using JMeter Maven Plugin, the simple pom.xml would be something like:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>jmeter-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<!-- Generate JMeter configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And output:
Alternatively you can use Taurus automation framework which has Pass/Fail criteria subsystem
Example configuration:
execution:
- scenario: simple
scenarios:
simple:
script: test.jmx
reporting:
- module: passfail
criteria:
- succ<100%, continue as failed
and output:
推荐阅读
- javascript - 如何让屏幕阅读器完成表列名的播报,暂停再播报列的补充信息?
- java - 为什么这个局部变量在 Java 中等于 null?
- google-apps-script - 根据用户输入搜索正确的范围
- assembly - 程序集打印错误的 ascii 字符
- resharper-9.0 - 为什么 resharper 在文件中添加 // unsed 注释
- html - 我无法点击无序列表中的链接
- node-sass - 使用 NPM 安装包的问题
- javascript - 从本地 API 获取数据
- python - 如何使用 Python 动态创建列表字典
- file - 有没有办法将流重定向到 lua 中的标准输入