[英]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>s
的exec-maven-plugin
在generate-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.