npm包已经安装在cloudbees上的问题

时间:2013-11-20 20:32:29

标签: node.js jenkins npm cloudbees karma-runner

我正在使用以下预构建脚本配置

运行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 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

这是我得到的错误

[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

令我印象深刻的是,在我的cloudbees未设置之前,相同的配置工作正常。有人可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

我不确定为什么会改变这种行为,但你可以用简单的方法修复脚本:

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

答案 1 :(得分:1)

我只是在我的环境中设置了相同的东西。

我使用-L而不是-f来测试存在 - 因为我正在寻找一个符号链接。

我还注意到博客文章中建议的符号链接路径不正确。见下面的更正。

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