如何从詹金斯的 Maven 目标文件夹中删除旧子文件夹?
How to delete old subfolder from maven target folder on jenkins?
我在 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/
...
更好和最简单的方法是使用以下 jenkins 插件:
https://wiki.jenkins-ci.org/display/JENKINS/Discard+Old+Build+plugin
https://groups.google.com/d/msg/gatling/z9slKmdw9-0/ZO01W55ACwAJ
您可以简单地使用 Jenkins 的删除工作区选项,然后每次构建应用程序时它都会删除以前的 运行 的工作区。
我会把结果存储在一个单独的目录中,并使用 Gatling 提供的 after hook 来执行这个 activity。
作为校长,您也不应该将重要的东西存储在目标文件夹中。
我在 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/
...
更好和最简单的方法是使用以下 jenkins 插件: https://wiki.jenkins-ci.org/display/JENKINS/Discard+Old+Build+plugin
https://groups.google.com/d/msg/gatling/z9slKmdw9-0/ZO01W55ACwAJ
您可以简单地使用 Jenkins 的删除工作区选项,然后每次构建应用程序时它都会删除以前的 运行 的工作区。
我会把结果存储在一个单独的目录中,并使用 Gatling 提供的 after hook 来执行这个 activity。 作为校长,您也不应该将重要的东西存储在目标文件夹中。