简体   繁体   English

Jenkins Maven项目构建外壳不可用

[英]Jenkins Maven Project Build shell not available

In Jenkins, I am using choice parameters plugin to allow a user to select which suite they would like to run. 在Jenkins中,我使用选择参数插件来允许用户选择他们要运行的套件。 The problem I'm having is when I try to alter the option chosen in the parameter section to append the directory and .xml prefix the job fails. 我遇到的问题是,当我尝试更改参数部分中选择的选项以追加目录和.xml前缀时,作业失败。 If I put the full name in the parameter and input it directly as a build data it works fine. 如果我在参数中输入全名,然后直接将其作为构建数据输入,则效果很好。 Below is my jenkins setup, pom and error. 以下是我的詹金斯设置,pom和错误。

Choice parameter data 选择参数数据

Name    choice
Choices CopyFunctionality
        CopyToFunctionality

Window batch shell command 窗口批处理Shell命令

@echo off

set SUITE=%choice%.xml

echo %SUITE%

Build values 建立价值

clean test -PParameterisedBuild -DsuiteXmlFile=${SUITE}

POM profile POM配置文件

<profile>
            <id>ParameterisedBuild</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.19.1</version>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>testNG XML Files\${SUITE}</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

Maven error Maven错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project Expert_Models: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] org.apache.maven.surefire.testset.TestSetFailedException: Suite file C:\Automation Framework\Jenkins\workspace\regression_tests_selectable\testNG XML Files\${SUITE} is not a valid file
[ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.locateTestSets(TestNGXmlTestSuite.java:98)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[JENKINS] Archiving C:\Automation Framework\Jenkins\workspace\regression_tests_selectable\pom.xml to com.ExpertModels/Expert_Models/0.1-SNAPSHOT/Expert_Models-0.1-SNAPSHOT.pom
[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:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
channel stopped
Finished: FAILURE
  1. Exclude suiteXmlFiles param from POM, there is no need to have this param since your system params would override it. 从POM中排除suiteXmlFiles参数,由于系统参数会覆盖此参数,因此不需要此参数。
  2. You don't need to set jenkins params using batch script, jenkins will parse params for you. 您不需要使用批处理脚本设置jenkins参数,jenkins会为您解析参数。
  3. Pass suite params to maven surefire plugin like: 将套件参数传递给Maven surefire插件,例如:

    clean test -PParameterisedBuild -Dsurefire.suiteXmlFile=${choice(or whatever the name of your choice param is)} 干净测试-PParameterisedBuild -Dsurefire.suiteXmlFile = $ {选择(或任何您选择的参数名称)}

PS Also I would recommend re-evaluate usage of profiles based on the info above, I'm pretty sure that in 99% of cases you could simply avoid having profiles. PS另外,我建议根据上述信息重新评估配置文件的使用情况,我敢肯定,在99%的情况下,您可以避免使用配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM