Java 是否可以在Jenkins中将testng.xml和test name作为单个参数传递?

Java 是否可以在Jenkins中将testng.xml和test name作为单个参数传递?,java,jenkins,selenium-webdriver,automation,continuous-integration,Java,Jenkins,Selenium Webdriver,Automation,Continuous Integration,我有以下testng.xml文件: <test name="Product_Listing_Page" enabled="true"> <parameter name="scenario.file.loc" value="scenarios/plp.bdd"></parameter> <groups> <run> <include name="REGRESSION" />

我有以下testng.xml文件:

<test name="Product_Listing_Page" enabled="true">
    <parameter name="scenario.file.loc" value="scenarios/plp.bdd"></parameter>
    <groups>
        <run>
            <include name="REGRESSION" />
        </run>
    </groups>

    <classes>
        <class name="client.text.BDDTestFactory"></class>
    </classes>
</test>

<test name="Registration" enabled="false">
    <parameter name="scenario.file.loc" value="scenarios/registration.bdd"></parameter>
    <groups>
        <run>
            <include name="REGRESSION" />
        </run>
    </groups>
    <classes>
        <class name="client.text.BDDTestFactory"></class>
    </classes>
</test>

我已经创建了一个Jenkins job作为maven项目,其中我将
testng.xml
文件名作为参数传递,比如
clean test-DSuiteXmlFile=config/testrun\u config.xml
,因为我也在构建后触发器中配置了
failed test.xml
。我正在寻找一种方法,可以将测试名称与命令一起传递


对此有什么想法吗?或者我需要尝试其他方法吗

使用以下命令将多个参数从Jenking传递到maven:

clean install compile test -DsuiteXmlFile=$TestNgFile -DOtherParamerer1=$ValueOfParameter1 -DOtherParameter2=$ValueOfParameter2 
如下图所示:

使用以下命令在pom.xml中接收这些值:

            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <skip>false </skip>
                <forkCount>0</forkCount>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                        <systemProperties>
                    <property>
                        <name>ValueOfParameter1</name>
                        <value>${OtherParamerer1}</value>
                    </property>
                    <property>
                        <name>ValueOfParameter2</name>
                        <value>${OtherParameter2}</value>
                    </property>
                </systemProperties>
            </configuration>
        </plugin>

让我知道它是否解决了您的问题。

您想为两个测试都通过一个参数吗?不,我只想通过测试名称,比如
test-DSuiteXmlFile=config/testrun\u config.xml
,这样我就可以只执行注册场景来运行特定场景,您可以尝试BDDWhy中的标记选项,您不需要传递两个参数,如果您需要如何从jenking接收多个参数的详细信息,请告诉我know@Ankit古普塔,是的,请告诉我。我试过了,但我想我做错了什么
static String  ValueOfParameter1=System.getProperty("ValueOfParameter1");
static String ValueOfParameter2= System.getProperty("ValueOfParameter2");