我必须编译谷歌聚合物资源,并将其放入特定的文件夹中,在本地(与Ubuntu Linux Shell集成的Windows 10)可以完美运行,但是在我的詹金斯(在Ubuntu 17.04 Server上的Docker容器中)上却无法运行。
我是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] ------------------------------------------------------------------------
我已经做了很多尝试来使其工作,但是没有任何帮助。
感谢您的帮助!
最佳答案
我的猜测是,这一切都是POM中的错字:
<rgument>
代替
<argument>
...发生在几个地方。检查出。
我的解释:我怀疑您在Windows 10 PC上已经存在
static
目录的非干净环境中运行测试,因此(错误地)创建目录static
的目标操作被忽略了。但是,当您在干净的环境(Ubuntu)上进行测试时,在static
阶段未创建generate-sources
目录,然后出现了错误。使用Maven进行构建时的一个好习惯是让
src
目录保持原样。如果必须在构建期间创建某些文件内容,则应在target
目录中生成这些文件内容。这样,使用clean
开始构建就足以确保删除target
目录,并且在干净的环境中开始构建。您可以在pom中做的另一项改进是将
<execution>s
阶段中所有exec-maven-plugin
的generate-sources
替换为只调用一个包含完整程序的自定义脚本的一个:mkdir static
npm install
node_modules/.bin/bower
...
这样,您的脚本程序将变得更具可读性。