Tomcat Jenkins 中的 Cargo Container 下载问题
Tomcat download issue in Cargo Container in Jenkins
我在 Jenkins 中遇到以下错误(我正在使用带 tomcat 的 cargo 插件进行集成测试)。
[2021-07-20T09:46:47.790Z] [ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.7.9:start (start-server) on project demo-prj-rest-test: Execution start-server of goal org.codehaus.cargo:cargo-maven2-plugin:1.7.9:start failed: Failed to download [https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/8.0.42/tomcat-8.0.42.zip]: java.net.ConnectException: Connection timed out (Connection timed out) -> [Help 1]
下面是我的cargo插件:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.9</version>
<configuration>
<container>
<timeout>600000</timeout>
<containerId>tomcat8x</containerId>
<type>installed</type>
<zipUrlInstaller>
<url>https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/8.0.42/tomcat-8.0.42.zip</url>
<downloadDir>${project.build.directory}/downloads</downloadDir>
<extractDir>${project.build.directory}/extracts</extractDir>
</zipUrlInstaller>
<output>${project.build.directory}/cargo-container.log</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<deployables>
<deployable>
<groupId>com.example</groupId>
<artifactId>demo-prj-war</artifactId>
<type>war</type>
<location>${project.build.directory}/demo-prj-war</location>
<properties>
<context>demo-prj-war</context>
</properties>
</deployable>
</deployables>
<configuration>
<type>standalone</type>
<home>${project.build.directory}/tomcat8x/container</home>
<configfiles>
<configfile>
<file>${project.basedir}/src/test/resources/war-dependencies/context.xml</file>
<todir>conf/</todir>
<tofile>context.xml</tofile>
</configfile>
</configfiles>
<properties>
<cargo.servlet.port>9090</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-server</id>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
</execution>
<execution>
<id>stop-server</id>
<goals>
<goal>stop</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
这在本地 Maven 构建中完美运行,所有集成测试运行 在货物 tomcat 中成功,但在 Jenkins 构建中面临上述问题。
一周后我们找到了这个问题的根本原因。插件配置没有问题。问题出在 Jenkins 方面(一个内存问题,货物中的 tomcat 服务刚刚关闭并且没有 return 任何有用的错误消息)。
解决方案:- 我们切换到不同的 Maven 管道。
我在 Jenkins 中遇到以下错误(我正在使用带 tomcat 的 cargo 插件进行集成测试)。
[2021-07-20T09:46:47.790Z] [ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.7.9:start (start-server) on project demo-prj-rest-test: Execution start-server of goal org.codehaus.cargo:cargo-maven2-plugin:1.7.9:start failed: Failed to download [https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/8.0.42/tomcat-8.0.42.zip]: java.net.ConnectException: Connection timed out (Connection timed out) -> [Help 1]
下面是我的cargo插件:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.9</version>
<configuration>
<container>
<timeout>600000</timeout>
<containerId>tomcat8x</containerId>
<type>installed</type>
<zipUrlInstaller>
<url>https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/8.0.42/tomcat-8.0.42.zip</url>
<downloadDir>${project.build.directory}/downloads</downloadDir>
<extractDir>${project.build.directory}/extracts</extractDir>
</zipUrlInstaller>
<output>${project.build.directory}/cargo-container.log</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<deployables>
<deployable>
<groupId>com.example</groupId>
<artifactId>demo-prj-war</artifactId>
<type>war</type>
<location>${project.build.directory}/demo-prj-war</location>
<properties>
<context>demo-prj-war</context>
</properties>
</deployable>
</deployables>
<configuration>
<type>standalone</type>
<home>${project.build.directory}/tomcat8x/container</home>
<configfiles>
<configfile>
<file>${project.basedir}/src/test/resources/war-dependencies/context.xml</file>
<todir>conf/</todir>
<tofile>context.xml</tofile>
</configfile>
</configfiles>
<properties>
<cargo.servlet.port>9090</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-server</id>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
</execution>
<execution>
<id>stop-server</id>
<goals>
<goal>stop</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
这在本地 Maven 构建中完美运行,所有集成测试运行 在货物 tomcat 中成功,但在 Jenkins 构建中面临上述问题。
一周后我们找到了这个问题的根本原因。插件配置没有问题。问题出在 Jenkins 方面(一个内存问题,货物中的 tomcat 服务刚刚关闭并且没有 return 任何有用的错误消息)。
解决方案:- 我们切换到不同的 Maven 管道。