2017-09-03 36 views
0

我必須編譯Google聚合資源,並將它們放入本地(與Linux Linux shell集成的Windows 10)的特定文件夾中,但在我的jenkins(它在Ubuntu 17.04服務器上進入Docker容器中)失敗。maven在本地工作,但在jenkins上使用javascript資源時失敗

我與詹金斯一個新手,這是我第一次測試它

POM的配置上GitHub

這裏管道的配置:

node { 
    def mvnHome 
    def nodeHome 
    stage('Preparation') { // for display purposes 
     // Get some code from a GitHub repository 
     git 'https://github.com/ITGuy9401/RPGMakerVXtoMVConverterWEB.git' 
     // Get the Maven tool. 
     // ** NOTE: This 'M3' Maven tool must be configured 
     // **  in the global configuration.   
     mvnHome = tool 'maven35' 
     nodeHome = tool 'nodejs840' 
     env.PATH = "${nodeHome}/bin:${mvnHome}/bin:${env.PATH}" 
    } 
    stage('Build') { 

     // Run the maven build 
     if (isUnix()) { 
     sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package" 
     } else { 
     bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean package/) 
     } 
    } 
    stage('Results') { 
     junit '**/target/surefire-reports/TEST-*.xml' 
     archive 'target/*.jar' 
    } 
} 

和有控制檯輸出

[INFO] ------------------------------------------------------------------------ 
[INFO] Building app 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ app --- 
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (clean-web-res) @ app --- 
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (prepare-resource-folder) @ app --- 
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (npm-install) @ app --- 
npm WARN [email protected] No repository field. 

up to date in 5.152s 
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (bower-build) @ app --- 
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (polymer-build) @ app --- 
info: Clearing build/ directory... 
info: (default) Building... 
info: (default) Build complete! 
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (test-list-files) @ app --- 
bower.json 
bower_components 
images 
index.html 
manifest.json 
src 
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (move-files) @ app --- 
cp: cannot stat 'dev-static/build/default/*': No such file or directory 
[ERROR] Command execution failed. 
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) 
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404) 
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166) 
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:804) 
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:751) 
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:313) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) 
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:191) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 

我做了很多嘗試使其成功,但沒有任何幫助。 感謝您的任何幫助!

回答

1

我的猜測是,這一切的原因是你的POM一個錯字:的

<rgument> 

代替

<argument> 

...發生在幾個地方。檢查出。

我的解釋:我懷疑你在非乾淨環境中運行了你的Windows 10 PC上的測試,其中static目錄已經存在,所以目錄操作(錯誤地)創建的目錄static被默默忽略。但是當您在乾淨的環境(Ubuntu)上測試時,在generate-sources階段沒有創建static目錄,然後出現錯誤。

當使用Maven構建時,一個很好的做法是讓src目錄一樣。如果必須在建築物中創建一些文件內容,則應該在target目錄內生成該文件內容。這樣,使用clean開始構建就足以確保刪除target目錄,並且在乾淨的環境中啓動構建。

而且你可以在你的POM中做的另一項改進是隻是一種調用一個自定義的腳本,它應包含完整的計劃,以取代exec-maven-plugin所有<execution>sgenerate-sources階段:

mkdir static 
npm install 
node_modules/.bin/bower 
... 

這樣,您的腳本程序變得更具可讀性。

+0

謝謝你,但是爲什麼行家沒有打印的DTD驗證錯誤? 的方式,固定

+0

現在我'試圖讓它建立在jenkins上,然後我會做一些重構來實現最佳實踐 –

+0

我明白了。這是錯誤嗎?在發生錯誤時,存在目錄'/src/main/resources/dev-static/build/default',並且其中有文件嗎? –

1

確保本地計算機上和Jenkins上的settings.xml相同。

添加-x您MVN命令,所以你可以看到哪些文件使用的是

相關問題