Question

I am trying to install karma to cloudbees/jenkins. I have added this script to pre-build:

# 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
[ -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

I am not sure what the [ command here ] || syntax means in bash. Can anyone please advise?

Here is the output from jenkins:

Started by user Balteo Balteo
Building remotely on s-50416de2 in workspace /scratch/jenkins/workspace/bignibou-unit
Checkout:bignibou-unit / /scratch/jenkins/workspace/bignibou-unit - hudson.remoting.Channel@24db3ed2:s-50416de2
Using strategy: Default
Last Built Revision: Revision 23e130fd7cb2df6a759a35d8085dd6a648efd142 (origin/master, origin/HEAD)
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 23e130fd7cb2df6a759a35d8085dd6a648efd142 (origin/master, origin/HEAD)
Checking out Revision 23e130fd7cb2df6a759a35d8085dd6a648efd142 (origin/master, origin/HEAD)
Warning : There are multiple branch changesets here
[bignibou-unit] $ /bin/sh -xe /tmp/hudson6754458045759014477.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
+ '[' -d node_modules/phantomjs ']'
+ '[' -d node_modules/karma ']'
+ '[' -d node_modules/karma-junit-reporter ']'
+ npm install -g karma-junit-reporter
npm http GET https://registry.npmjs.org/karma-junit-reporter
npm http 304 https://registry.npmjs.org/karma-junit-reporter
npm http GET https://registry.npmjs.org/xmlbuilder/0.4.2
npm http 304 https://registry.npmjs.org/xmlbuilder/0.4.2
karma-junit-reporter@0.1.0 /scratch/jenkins/addons/node/node-0.11.1-x86_64/lib/node_modules/karma-junit-reporter
└── xmlbuilder@0.4.2
+ '[' -d node_modules/karma-phantomjs-launcher ']'
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 47241
<===[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
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building bignibou 0.1.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- apt-maven-plugin:1.0.6:process (default) @ bignibou ---
[INFO] 
[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.orm.jpa.aspectj.JpaExceptionTranslatorAspect 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]
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ bignibou ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 44 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ bignibou ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- aspectj-maven-plugin:1.2:test-compile (default) @ bignibou ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ bignibou ---[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] Copying 9 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ bignibou ---
[INFO] Compiling 7 source files to /scratch/jenkins/workspace/bignibou-unit/target/test-classes
[INFO] 
[INFO] --- maven-karma-plugin:1.3:start (karma) @ bignibou ---
karma start /scratch/jenkins/workspace/bignibou-unit/karma/config/karma.conf.js --browsers PhantomJS --single-run

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:51.674s
[INFO] Finished at: Sat Oct 26 13:19:31 EDT 2013
[INFO] Final Memory: 35M/124M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /scratch/jenkins/workspace/bignibou-unit/pom.xml to /home/balteo/hudson_home/jobs/bignibou-unit/modules/com.bignibou$bignibou/builds/2013-10-26_13-17-27/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.3: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.3: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:79)
    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:158)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
    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$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    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:724)
Caused by: org.apache.maven.plugin.MojoExecutionException: There was an error executing Karma.
    at com.kelveden.karma.StartMojo.createKarmaProcess(StartMojo.java:196)
    at com.kelveden.karma.StartMojo.execute(StartMojo.java:124)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 27 more
Caused by: java.io.IOException: Cannot run program "karma": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
    at com.kelveden.karma.StartMojo.createKarmaProcess(StartMojo.java:192)
    ... 30 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)
    ... 31 more
channel stopped
[bignibou-unit] $ /bin/sh -xe /tmp/hudson7183929021886933853.sh
Finished: FAILURE
Was it helpful?

Solution

Adding the following lines to the bottom of the script sorted the issue:

[ -d $HOME/bin ] || mkdir $HOME/bin
[ -f $HOME/bin/karma ] || ln -s /scratch/jenkins/addons/node/$node_name/bin/karma $HOME/bin/karma
[ -f $HOME/bin/node ] || ln -s /scratch/jenkins/addons/node/$node_name/bin/node $HOME/bin/node
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top