遇到NPM / Karma和Cloudbees的麻烦

时间:2013-11-22 22:11:45

标签: maven jenkins npm cloudbees

我有以下预构建脚本:

# install nodejs, if using cloudbees
curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.1 source ./use-node

# install phantomjs, karma
npm cache clean
[ -d node_modules/phantomjs ] || npm install -g phantomjs
[ -d node_modules/karma ] || npm install -g karma
[ -d node_modules/karma-junit-reporter ] || npm install -g karma-junit-reporter
[ -d node_modules/karma-phantomjs-launcher ] || npm install -g  karma-phantomjs-launcher

test -d $HOME/bin  || mkdir $HOME/bin
test -L $HOME/bin/karma  || ln -s /scratch/jenkins/addons/node/$node_name/bin/karma $HOME/bin/karma
test -L $HOME/bin/node  || ln -s /scratch/jenkins/addons/node/$node_name/bin/node $HOME/bin/node

上述脚本失败,并显示以下错误消息:

Started by user Balteo Balteo
Building remotely on s-b13180e5 in workspace /scratch/jenkins/workspace/bignibou-unit
Checkout:bignibou-unit / /scratch/jenkins/workspace/bignibou-unit - hudson.remoting.Channel@e764b98:s-b13180e5
Using strategy: Default
Last Built Revision: Revision 66fc46cd3b57973b88969981cd25872b36fbd3db (origin/HEAD, origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Seen 2 remote branches
Commencing build of Revision 66fc46cd3b57973b88969981cd25872b36fbd3db (origin/HEAD, origin/master)
Checking out Revision 66fc46cd3b57973b88969981cd25872b36fbd3db (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here
[bignibou-unit] $ /bin/sh -xe /tmp/hudson5627362406349041774.sh
+ curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
+ NODE_VERSION=0.11.1
+ source ./use-node
++ [[ -z 0.11.1 ]]
++ set -e
++ mkdir -p /scratch/jenkins/addons/node
+++ uname -m
++ ARCH=x86_64
++ node_name=node-0.11.1-x86_64
++ test -f /scratch/jenkins/addons/node/node-0.11.1-x86_64.tar.bz2
++ test -f /scratch/jenkins/addons/node/node-0.11.1-x86_64/bin/node
++ export PATH=/scratch/jenkins/addons/node/node-0.11.1-x86_64/bin:/opt/maven/latest/bin:/opt/jdk/jdk1.7.latest/bin:/opt/jdk/jdk1.7.latest/bin:/opt/jdk/latest/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/opt/maven/latest/bin:/opt/ant/latest/bin:/opt/android/android-sdk-linux/tools:/opt/gradle/latest/bin:/home/jenkins/bin:/opt/jdk/jdk.latest/bin
++ PATH=/scratch/jenkins/addons/node/node-0.11.1-x86_64/bin:/opt/maven/latest/bin:/opt/jdk/jdk1.7.latest/bin:/opt/jdk/jdk1.7.latest/bin:/opt/jdk/latest/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/opt/maven/latest/bin:/opt/ant/latest/bin:/opt/android/android-sdk-linux/tools:/opt/gradle/latest/bin:/home/jenkins/bin:/opt/jdk/jdk.latest/bin
+ npm cache clean
+ '[' -d node_modules/phantomjs ']'
+ '[' -d node_modules/karma ']'
+ '[' -d node_modules/karma-junit-reporter ']'
+ '[' -d node_modules/karma-phantomjs-launcher ']'
+ test -d /home/jenkins/bin
+ test -L /home/jenkins/bin/karma
+ test -L /home/jenkins/bin/node
Parsing POMs
[bignibou-unit] $ /opt/jdk/jdk1.7.latest/bin/java -cp /scratch/jenkins/maven3-agent.jar:/opt/maven/latest/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /opt/maven/latest /scratch/jenkins/slave.jar /scratch/jenkins/maven3-interceptor.jar /scratch/jenkins/maven3-interceptor-commons.jar 59804
<===[JENKINS REMOTING CAPACITY]===>channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven:  -B -f /scratch/jenkins/workspace/bignibou-unit/pom.xml test
Nov 22, 2013 5:02:12 PM org.apache.maven.cli.event.ExecutionEventLogger projectDiscoveryStarted
INFO: Scanning for projects...
Nov 22, 2013 5:02:15 PM org.apache.maven.cli.event.ExecutionEventLogger projectStarted
INFO:                                                                         
Nov 22, 2013 5:02:15 PM org.apache.maven.cli.event.ExecutionEventLogger projectStarted
INFO: ------------------------------------------------------------------------
Nov 22, 2013 5:02:15 PM org.apache.maven.cli.event.ExecutionEventLogger projectStarted
INFO: Building bignibou 0.1.0.BUILD-SNAPSHOT
Nov 22, 2013 5:02:15 PM org.apache.maven.cli.event.ExecutionEventLogger projectStarted
INFO: ------------------------------------------------------------------------
Downloading: https://repository-balteo.forge.cloudbees.com/snapshot/org/springframework/security/spring-security-core/3.2.0.CI-SNAPSHOT/maven-metadata.xml
Downloading: https://repository-balteo.forge.cloudbees.com/snapshot/org/springframework/security/spring-security-config/3.2.0.CI-SNAPSHOT/maven-metadata.xml
Downloading: https://repository-balteo.forge.cloudbees.com/snapshot/org/springframework/security/spring-security-web/3.2.0.CI-SNAPSHOT/maven-metadata.xml
Downloading: https://repository-balteo.forge.cloudbees.com/snapshot/org/springframework/security/spring-security-taglibs/3.2.0.CI-SNAPSHOT/maven-metadata.xml
Downloading: https://repository-balteo.forge.cloudbees.com/snapshot/org/springframework/security/spring-security-acl/3.2.0.CI-SNAPSHOT/maven-metadata.xml
Nov 22, 2013 5:02:28 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:02:28 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- apt-maven-plugin:1.0.6:process (default) @ bignibou ---
Nov 22, 2013 5:02:55 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:02:55 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- aspectj-maven-plugin:1.2:compile (default) @ bignibou ---
[WARNING] advice defined in com.bignibou.aop.AdvertisementExistsAndBelongsToMemberCheckAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in com.bignibou.aop.AdvertisementExistsCheckAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
Nov 22, 2013 5:04:08 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:04:08 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- maven-resources-plugin:2.6:resources (default-resources) @ bignibou ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 44 resources
Nov 22, 2013 5:04:10 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:04:10 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- maven-compiler-plugin:2.5.1:compile (default-compile) @ bignibou ---
[INFO] Nothing to compile - all classes are up to date
Nov 22, 2013 5:04:15 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:04:15 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- aspectj-maven-plugin:1.2:test-compile (default) @ bignibou ---
Nov 22, 2013 5:04:16 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:04:16 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- maven-resources-plugin:2.6:testResources (default-testResources) @ bignibou ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
Nov 22, 2013 5:04:17 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:04:17 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ bignibou ---
[INFO] Nothing to compile - all classes are up to date
Nov 22, 2013 5:04:18 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: 
Nov 22, 2013 5:04:18 PM org.apache.maven.cli.event.ExecutionEventLogger mojoStarted
INFO: --- maven-karma-plugin:1.5:start (karma) @ bignibou ---
karma start /scratch/jenkins/workspace/bignibou-unit/karma/config/karma.conf.js --browsers PhantomJS --single-run

Nov 22, 2013 5:04:19 PM org.apache.maven.cli.event.ExecutionEventLogger logResult
INFO: ------------------------------------------------------------------------
Nov 22, 2013 5:04:19 PM org.apache.maven.cli.event.ExecutionEventLogger logResult
INFO: BUILD FAILURE
Nov 22, 2013 5:04:19 PM org.apache.maven.cli.event.ExecutionEventLogger logStats
INFO: ------------------------------------------------------------------------
Nov 22, 2013 5:04:19 PM org.apache.maven.cli.event.ExecutionEventLogger logStats
INFO: Total time: 2:06.425s
Nov 22, 2013 5:04:19 PM org.apache.maven.cli.event.ExecutionEventLogger logStats
INFO: Finished at: Fri Nov 22 17:04:19 EST 2013
Nov 22, 2013 5:04:19 PM org.apache.maven.cli.event.ExecutionEventLogger logStats
INFO: Final Memory: 27M/117M
Nov 22, 2013 5:04:19 PM org.apache.maven.cli.event.ExecutionEventLogger sessionEnded
INFO: ------------------------------------------------------------------------
[JENKINS] Archiving /scratch/jenkins/workspace/bignibou-unit/pom.xml to /home/balteo/hudson_home/jobs/bignibou-unit/modules/com.bignibou$bignibou/builds/2013-11-22_22-01-58/archive/com.bignibou/bignibou/0.1.0.BUILD-SNAPSHOT/bignibou-0.1.0.BUILD-SNAPSHOT.pom
Waiting for Jenkins to finish collecting data
mavenExecutionResult exceptions not empty
message : Failed to execute goal com.kelveden:maven-karma-plugin:1.5:start (karma) on project bignibou: There was an error executing Karma.
cause : There was an error executing Karma.
Stack trace : 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.kelveden:maven-karma-plugin:1.5:start (karma) on project bignibou: There was an error executing Karma.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:178)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:129)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:67)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.maven.plugin.MojoExecutionException: There was an error executing Karma.
    at com.kelveden.karma.StartMojo.createKarmaProcess(StartMojo.java:209)
    at com.kelveden.karma.StartMojo.execute(StartMojo.java:133)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 30 more
Caused by: java.io.IOException: Cannot run program "karma" (in directory "/scratch/jenkins/workspace/bignibou-unit"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
    at com.kelveden.karma.StartMojo.createKarmaProcess(StartMojo.java:205)
    ... 33 more
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
    ... 34 more
channel stopped
[bignibou-unit] $ /bin/sh -xe /tmp/hudson6880094858310082268.sh
Finished: FAILURE

2 个答案:

答案 0 :(得分:2)

我根据以下博客文章尝试了同样的事情并且遇到了同样的问题。 http://jespertejlgaard.blogspot.com/2013/09/how-to-execute-your-maven-karma-plugin.html

我最终发现符号链接的业力路径不正确。

应该是

test -L $HOME/bin/karma || ln -s /scratch/jenkins/addons/node/$node_name/lib/node_modules/karma/bin/karma $HOME/bin/karma

此外,由于该符号链接可能已经存在,您可能希望删除&#34;测试&#34;部分第一次执行,以便正确创建符号链接(可能需要-sF),然后将其放回原处。我这样做是为了以防万一。

答案 1 :(得分:1)

阅读日志我怀疑你正在运行两个单独的构建步骤?

如果是这样,那么您需要记住步骤之间不保留环境变量。

所以你的第二个maven步骤看不到业力/节点等。

尝试将这两个步骤结合起来。

如果您使用的是Jenkins Maven插件,那么请注意,它会导致更多问题。