我是maven和maven个人档案的新手。我正在从事自动化专家项目,并且我正在尝试创建不同的配置文件。我想要做的是每个配置文件将根据激活的配置文件运行不同的xmlsuites。
<profiles>
<profile>
<id>Jenkins</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<suiteXmlFiles>
<echo>Jenkins profile</echo>
<suiteXmlFiles>xml/jenkins.xml</suiteXmlFiles>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Ticket</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<suiteXmlFiles>
<echo>Ticket profile</echo>
<suiteXmlFiles>xml/Tickets.xml</suiteXmlFiles>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
以上就是我所做的。我希望有人可以帮我提一下如何做到这一点。
现在,我在jenkins上运行自动化时遇到以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire- plugin:2.17:test (default-test) on project ipos: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was an error in the forked process
[ERROR] org.apache.maven.surefire.testset.TestSetFailedException: Suite file C:\Program Files (x86)\Jenkins\workspace\Automatizacion IPOS\Ticket profile is not a valid file
[ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.locateTestSets(TestNGXmlTestSuite.java:116)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:84)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
由于
答案 0 :(得分:1)
然后,最干净的实现是使用插件的单个配置来运行每个构建,并简单地定义一个属性令牌,该令牌因配置文件而异。
<profiles>
<profile>
<id>Jenkins</id>
<properties>
<my.echo>Jenkins profile</my.echo>
<my.xml.files>xml/jenkins.xml</my.xml.files>
</properties>
</profile>
<profile>
<id>Ticket</id>
<properties>
<my.echo>Ticket profile</my.echo>
<my.xml.files>xml/Tickets.xml</my.xml.files>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<suiteXmlFiles>
<!-- DELETE THIS LINE: IS A TYPO
<echo>Ticket profile</echo>
-->
<!-- PROFILE-DRIVEN SUBSTITUTION -->
<echo>${my.echo}</echo>
<suiteXmlFiles>${my.xml.files}</suiteXmlFiles>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
希望有所帮助。