![](/img/trans.png)
[英]Jenkins: Maven project with modules that won't be build: no pom.xml found
[英]Maven Project with multi modules is unable to find pom.xml of modules - Jenkins/Eclipse
我在 Jenkins 上创建了一个 Maven 项目,它将从 Butbucket 克隆一个 mercurial 分支,因此我可以运行我的 Selenium TestNG 脚本。 我尝试清除工作区以获得干净的构建,但它导致了与以前相同的错误。 此外,我检查了 jenkins 工作区中 pom.xml 文件的每个模块,它们都存在。 单击控制台中错误报告的图像。 我不明白为什么 Jenkins 和 Eclipse 在同一个项目文件夹中时都找不到我的依赖项的 pom.xml 文件。
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>
<parent>
<artifactId>PSWebTestFramework</artifactId>
<groupId>com.guidewire.pstesting</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>pswtf-test-tp-pc</artifactId>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>com.guidewire.pstesting</groupId>
<artifactId>pswtf-application-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.guidewire.pstesting</groupId>
<artifactId>pswtf-test-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.guidewire.pstesting</groupId>
<artifactId>pswtf-test-tp-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.guidewire.pstesting</groupId>
<artifactId>pswtf-application-tp-pc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.guidewire.pstesting</groupId>
<artifactId>pswtf-application-ootb-pc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<excludes>META-INF/*.SF</excludes>
<excludes>META-INF/*.DSA</excludes>
<excludes>META-INF/*.RSA</excludes>
<argLine>-Dorg.uncommons.reportng.escape-output=false</argLine> <!-- get html in reports rather than string -->
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value> <!-- disabling default listeners is optional -->
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter, org.testng.reporters.XMLReporter</value>
</property>
</properties>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/src/test/conf</additionalClasspathElement>
<additionalClasspathElement>${basedir}/src/test/testdata</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
更新:根据下面的解决方案,我改变了我的工作配置,并根据下图,我能够获得成功而不是失败。
您附加的屏幕截图中的错误意味着工件 ID“pswtf-test-tp-pc”无法在本地 Maven 存储库中找到依赖项。
使用 maven <modules>
标签从父 POM 构建所有项目。 将此添加到父文件夹的 pom.xml 中,工件 ID 为 PSWebTestFramework。 首先运行这个父 pom,然后从你的项目中运行 - pswtf-test-tp-pc
<modules>
<module>pswtf-application-core</module>
<module>pswtf-test-core</module>
<module>pswtf-test-tp-core</module>
<module>pswtf-application-tp-pc</module>
</modules>
这应该构建每个模块并将其安装在本地 maven 存储库中。
PS - 使用mvn clean install
命令在本地 repo 中安装依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.