سؤال

I am running Cloudbees with the following pre-build script config:

# 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 phantomjs
[ -d node_modules/karma ] || npm install karma
[ -d node_modules/karma-junit-reporter ] || npm install  karma-junit-reporter
[ -d node_modules/karma-phantomjs-launcher ] || npm install  karma-phantomjs-launcher

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

Here is the error I get:

[bignibou-unit] $ /bin/sh -xe /tmp/hudson1843348359516925007.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 ']'
+ '[' -d /home/jenkins/bin ']'
+ '[' -f /home/jenkins/bin/karma ']'
+ ln -s /scratch/jenkins/addons/node/node-0.11.1-x86_64/bin/karma /home/jenkins/bin/karma
ln: failed to create symbolic link `/home/jenkins/bin/karma': File exists
Build step 'Execute shell' marked build as failure
[bignibou-unit] $ /bin/sh -xe /tmp/hudson7240697467917683493.sh
Finished: FAILURE

What strikes me is that the very same config used to work fine before my cloudbees was unprovisioned. Can anyone please help?

هل كانت مفيدة؟

المحلول

I just set up the same thing in my environment.

I used -L rather than -f to test existence -- since I'm looking for a symlink.

I also noticed that the symlink path suggested in the blog post was incorrect. See correction below.

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

نصائح أخرى

I'm not sure why this changed behavior, but you can fix you script with a simple:

test -L /home/jenkins/bin/karma || ln -s /scratch/jenkins/addons/node/node-0.11.1-x86_64/bin/karma /home/jenkins/bin/karma

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top