简体   繁体   English

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

[英]Issue with npm package being already installed on cloudbees

I am running Cloudbees with the following pre-build script config : 我正在使用以下预构建脚本配置运行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

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. 令我印象深刻的是,在我的cloudbees未被提供之前,相同的配置曾经工作正常。 Can anyone please help? 有人可以帮忙吗?

I'm not sure why this changed behavior, but you can fix you script with a simple: 我不确定为什么会改变这种行为,但你可以用简单的方法修复脚本:

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

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. 我使用-L而不是-f来测试存在 - 因为我正在寻找一个符号链接。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM