我在Jenkins的一个单独的maven项目中使用gatling。 Gatling在jenkins的目标文件夹中创建报告。如何删除生成的报告除了最后15 ?
我尝试使用maven-invoker-plugin和beanshell脚本来完成它。有没有更好的办法? maven-invoker-plugin不起作用。我有一个错误:
[INFO] --- maven-inviker-plugin:1.6:integration-test (integration-test) @ gatling-loadtests ---
[INFO] No project were selected for execution
这是pom.xml
<?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>vf.gatling.loadtests</groupId>
<artifactId>gatling-loadtests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gatling-loadtests</name>
<description>Demo project for Gatling loadtests</description>
<properties>
<source.property>1.8</source.property>
<target.property>1.8</target.property>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gatling.version>2.2.3</gatling.version>
<gatling-plugin.version>2.2.1</gatling-plugin.version>
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-plugin.version}</version>
<configuration>
<runMultipleSimulations>false</runMultipleSimulations>
<includes>
<param>${simulation}</param>
</includes>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Plugin for Post-Build-Script -->
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>1.6</version>
<configuration>
<debug>true</debug>
<projectsDirectory>test/beanshell</projectsDirectory>
<postBuildHookScript>postbuild_delete_old_reports.bsh</postBuildHookScript>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
这是项目结构
./
+- pom.xml
+- src/
+- test/
+- beanshell/
| +- postbuild_delete_old_reports.bsh
+- resources/
...
+- scala/
...
+- target/
+- gatling/
+- loadscenario-1479475762095/
+- js/
+- style/
+- index.html
...
+- loadscenario-1479475768887/
+- loadscenario-1479477505729/
+- loadscenario-1479479138171/
+- loadscenario-1479479173198/
+- genarated-test-sources/
+- invoker-reports/
+- maven-archiver/
+- test-classes/
...
答案 0 :(得分:0)
有更好,最简单的方法是使用以下jenkins插件: https://wiki.jenkins-ci.org/display/JENKINS/Discard+Old+Build+plugin
https://groups.google.com/d/msg/gatling/z9slKmdw9-0/ZO01W55ACwAJ
答案 1 :(得分:0)
您可以简单地使用Jenkins的删除工作区选项,然后每次构建应用程序时,它都会删除上一次运行的工作区。
答案 2 :(得分:0)
我会将结果存储在一个单独的目录中,并使用Gatling提供的挂钩来执行此活动。 作为校长,您不应将重要的东西存储在目标文件夹中。