2017-03-06 43 views
1

我試圖安裝和使用NVM從詹金斯Ubuntu的服務器上執行shell腳本,但我收到此錯誤:NVM是不工作的詹金斯執行shell

16:00:21 /tmp/hudson5983664925305072739.sh: line 8: nvm: command not found

這是我曾嘗試那些使遠,但沒有成功:

#!/bin/bash 

touch ~/.profile && source ~/.profile; 
nvm current || echo "SSH NVM is being installed" && touch ~/.profile && curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh -o install_nvm.sh && bash install_nvm.sh && source ~/.profile 

echo "checking nvm" 
bash ~/.nvm/nvm.sh; 
nvm --version || exit 1; 

詹金斯執行shell截圖:

enter image description here

回答

1

添加那些解決問題:

. ~/.nvm/nvm.sh 
. ~/.profile 
. ~/.bashrc 
1

您需要記住,Jenkins正在非交互式shell中運行命令,所以PATH與普通用戶有所不同。解決這個問題的一種方法是用絕對路徑調用nvm。