ubuntu - NVM 不适用于 Jenkins execute shell

标签 ubuntu jenkins continuous-integration nvm

我正在尝试在 Ubuntu 服务器上安装和使用 Jenkins 执行 shell 脚本中的 nvm,但出现此错误:

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;

Jenkins 执行 shell 截图:

enter image description here

最佳答案

添加这些可以解决问题:

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

关于ubuntu - NVM 不适用于 Jenkins execute shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42627037/

相关文章:

jenkins - 哪个 URL 将获得上一个 Jenkins 作业的状态代码(结果)?

bash - 如何简化 YAML CircleCI 配置以获得更好的可读性?

git - 如何使用 buildbot 设置 git 提交后 Hook

PHP:使用未定义的常量 ENT_HTML5 - 假定为 'ENT_HTML5'

c - 为什么我的信号处理程序不处理 SIGKILL,有时会导致帐户注销

bash - 设置可执行文件的 bash TAB 自动完成参数候选

git - 如何从 Jenkins 中的构建中排除 git 分支

continuous-integration - 如何清理符号存储?

ubuntu - Laravel 4 ubuntu Composer 安装/更新错误

python - 在 Ubuntu 上使用 pip 安装 NumPy 失败