简体   繁体   English

Maven在本地工作,但是在使用javascript资源时无法在jenkins上工作

[英]maven works on local but fails on jenkins when working with javascript resources

I've to compile google polymer resources, and put them into a specific folder, in local (windows 10 with Ubuntu Linux shell integration) works flawlessly, but on my jenkins (which is into a Docker container, on Ubuntu 17.04 Server) it fails. 我必须编译谷歌聚合物资源,并将其放入特定的文件夹中,在本地(与Ubuntu Linux Shell集成的Windows 10)可以正常工作,但是在我的詹金斯(在Ubuntu 17.04 Server上的Docker容器中)上,它失败了。

I'm a newbie with Jenkins, this is my first test with it 我是Jenkins的新手,这是我的第一次测试

The pom configuration is on GitHub pom配置在GitHub上

Here the configuration of the pipeline: 这里是管道的配置:

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'
   }
}

and there is the console output 并且有控制台输出

[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 polymer-starter-kit@ 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] ------------------------------------------------------------------------

I've did a lot of attempts to make it works, but nothing was helpful. 我已经做了很多尝试来使其工作,但是没有任何帮助。 Thanks in advice for any help! 感谢您的帮助!

My guess is that the cause of it all is a typo in your POM: 我的猜测是,这一切都是POM中的错字:

<rgument>

instead of 代替

<argument>

... which occur in several places. ...发生在几个地方。 Check that out. 检查出。

My explanation: I suspect that you ran your tests in your Windows 10 PC on a non-clean environment, where a static directory already exists, so the goal action that (wrongly) created Directory static was silently ignored. 我的解释:我怀疑您是在Windows 10 PC上的非干净环境中运行测试的,该环境已经存在static目录,因此(错误地)创建Directory static的目标操作被忽略了。 But when you tested on a clean environment (the Ubuntu), the static directory was not created during the generate-sources phase, and then the error arose. 但是,当您在干净的环境(Ubuntu)上进行测试时,未在generate-sources阶段创建static目录,然后出现了错误。

A good practice when building with Maven is to let the src directory as is . 使用Maven进行构建时的一个好习惯是让src目录保持原样 If some file content must be created during the building, it should be generated within the target directory. 如果必须在构建期间创建一些文件内容,则应在target目录中生成这些文件内容。 In that way, starting your build with a clean is enough to ensure the target directory is removed, and the build is started on a clean environment. 这样,以clean方式启动构建足以确保删除target目录,并在干净的环境上启动构建。

And another improvement you could do in your pom is to replace all the <execution>s of exec-maven-plugin in the generate-sources phase by just one which calls one custom script which shall contain the full program: 而你可以在你的POM中做的另一项改进是更换所有的<execution>sexec-maven-plugingenerate-sources的只是一种调用一个自定义的脚本其中应包含完整的程序阶段:

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

In this way, your scripting program becomes more readable. 这样,您的脚本程序将变得更具可读性。

make sure the settings.xml on your local machine and on Jenkins is the same. 确保本地计算机和Jenkins上的settings.xml相同。

add -x to your mvn command so you can see which file you are using 在您的mvn命令中添加-x ,这样您就可以查看正在使用的文件

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

相关问题 Javascript间歇性失败,但刷新页面后即可使用 - Javascript fails intermittently but works when page is refreshed Javascript幻灯片无法正常运行; 在本地工作,但上传时不工作 - Javascript slideshow not working; works locally but not when uploaded javascript代码可单独运行,但在同一页面上使用时将失败 - javascript code works individually but fails when used on the same page Javascript日期可用于临时对象,但在首次分配给变量时会失败 - Javascript Date works with temporaries but fails when first assigned to a variable javascript fetch() 使用断点,但在正常运行时失败并显示 TypeError - javascript fetch() works with breakpoints, but fails with TypeError when run normally Javascript可在jsfiddle上运行,但在浏览器中打开本地html时不起作用 - Javascript works on a jsfiddle but does not work when opening the local html on a browser 当本地构建工作正常时,heroku 部署不起作用 - NodeJS 超时 - heroku deploy not working when local build works fine - NodeJS Timeout Javascript 验证有效......但失败 - Javascript validation works...and fails Javascript:setAttribute工作,getAttribute失败 - Javascript: setAttribute works, getAttribute fails Kibana UI 无法加载资源(javascript 和 css) - Kibana UI fails to load resources (javascript and css)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM