2017-04-11 175 views
0

嗨我對詹金斯很陌生,我使用選擇參數插件來允許用戶選擇他們想要運行的套件。我遇到的問題是當我嘗試更改參數部分中選擇的選項以追加目錄和.xml前綴時,作業失敗。如果我將全名放在參數中,並將其作爲構建數據直接輸入,則工作正常。下面是我的詹金斯設置,POM和錯誤。任何幫助,將不勝感激Jenkins Maven項目Biuld外殼不可用

選擇參數數據

Name choice 
Choices CopyFunctionality 
     CopyToFunctionality 

窗口一批shell命令

@echo off 

set SUITE=%choice%.xml 

echo %SUITE% 

構建值

clean test -PParameterisedBuild -DsuiteXmlFile=${SUITE} 

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] 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 

回答

0
  1. 排除從POM suiteXmlFiles PARAM,沒有必要有這個PARAM因爲你的系統PARAMS將覆蓋它。
  2. 你不需要使用批處理腳本來設置jenkins params,jenkins會爲你解析params。
  3. 通行證套房PARAMS到Maven保命插件,如:

    乾淨的測試-PParameterisedBuild -Dsurefire.suiteXmlFile = $ {選擇(或任何你選擇參數的時名稱爲)}

附:另外,我建議根據以上信息重新評估配置文件的使用情況,我非常確定,在99%的情況下,您可以簡單地避免使用配置文件。