我要编译谷歌聚合物资源,并把它们放到一个特定的文件夹中,在本地(Windows 10与Ubuntu Linux shell集成)工作完美无缺,但在我的jenkins(这是一个Docker容器,在Ubuntu 17.04服务器上)它失败了。
我是Jenkins的新手,这是我第一次用它测试
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 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] ------------------------------------------------------------------------
我已经做了很多努力使其有效,但没有任何帮助。 感谢您提供任何帮助!
答案 0 :(得分:1)
我的猜测是,这一切的原因都是你POM中的拼写错误:
<rgument>
而不是
<argument>
......发生在几个地方。检查一下。
我的解释:我怀疑您在非干净环境中运行Windows 10 PC中的测试,其中已存在static
目录,因此目标操作(错误地)创建了目录{{1}被默默地忽略了。但是当您在干净的环境(Ubuntu)上进行测试时,static
阶段期间未创建static
目录,然后出现错误。
使用Maven构建时的一个好习惯是让generate-sources
目录保持原样。如果必须在构建期间创建某些文件内容,则应在src
目录中生成该文件内容。这样,使用target
开始构建就足以确保删除clean
目录,并在干净的环境中启动构建。
您可以在pom中执行的另一项改进是将target
阶段中<execution>s
的所有exec-maven-plugin
替换为只调用一个自定义脚本的generate-sources
,该脚本应包含完整的程序:
mkdir static
npm install
node_modules/.bin/bower
...
通过这种方式,您的脚本程序变得更具可读性。
答案 1 :(得分:1)
确保本地计算机和Jenkins上的settings.xml是相同的。
将-x
添加到您的mvn命令,以便您可以查看正在使用的文件