簡體   English   中英

在Jenkins中執行SSH命令時,bash配置文件與以相同用戶通過SSH連接時不同

[英]When executing an SSH command in Jenkins, the bash profile is different to when connecting over SSH with the same user

我正在嘗試使用Jenkins SSH exec功能在遠程服務器上運行一些CLI nodejs命令。

嘗試永久運行時,我收到一條錯誤消息,該消息是我在npm上全局安裝的。

編輯 :錯誤是; -bash: forever: command not found

以root身份通過SSH連接並運行which npm返回;

/root/local/bin/npm

而通過Jenkins,以與root相同的命令返回;

/usr/bin/npm

我試過設置bash變量,但這些變量在兩種連接介質之間似乎也不一致。

兩者都使用此處詳細介紹的top方法安裝; https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh

嘗試這個:

ssh user@host -t 'bash -l -c "forever"'

您可以和man ssh一起閱讀:

如果指定了命令,那么它將在遠程主機而不是登錄shell上執行。

沒有login shell沒有rc-files.bashrc.bash_profile等),因此可能沒有您期望的$PATH

要了解有關登錄Shell的更多信息,請檢查man bash並搜索-l選項說明。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM