0

我正在尝试从 Jenkins 启动 Vagrant VM。我在“启动 Vagrant VM”中给出了 Vagrantfile 路径。当作业运行时,我收到以下错误:

Failed to iterate on remote directory vagrant_projs
[ vagrant ]: Executing command :[vagrant, up] in folder /Users/abc/Desktop/vagrant_projs
[vagrant_projs] $ vagrant up
[ vagrant ]: Error starting up vagrant, caught IOException, message: Cannot run program "vagrant" (in directory "/Users/abc/Desktop/vagrant_projs"): error=13, Permission denied
[ vagrant ]: [Ljava.lang.StackTraceElement;@5e144dc9
Build step 'Boot up Vagrant VM' marked build as failure
Finished: FAILURE

我认为这可能是因为 Vagrantfile 的权限,因此我手动对其进行了 chmod 777 。即使在那之后它给了我同样的错误。

更新: 我将Vagrantfile所在的文件夹从桌面移动到用户文件夹,我得到了不同的堆栈跟踪。

[workspace] $ vagrant -v
Vagrant 1.7.2
[ vagrant ]: Executing command :[vagrant, up] in folder /Users/abalan15/vagrant_projs
[vagrant_projs] $ vagrant up
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `unlink': Permission denied - /Users/abalan15/vagrant_projs/.vagrant/machines/default/virtualbox/id (Errno::EACCES)
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `delete'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `id='
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:142:in `initialize'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:75:in `new'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:75:in `machine'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:614:in `machine'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:168:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:74:in `block in execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:277:in `block (2 levels) in batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `tap'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `block in batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `synchronize'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:58:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/cli.rb:42:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:301:in `cli'
from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.2/bin/vagrant:174:in `<main>'
Build step 'Boot up Vagrant VM' marked build as failure
Finished: FAILURE
4

2 回答 2

1

最后!当我们尝试从 Jenkins(使用 vagrant 插件)调用/启动 Vagrant VM 时,将调用.vagrant.d带有 vagrantfile 的文件夹。应授予 jenkins 用户对这些文件夹的权限。

在 mac 中,右键单击这些文件夹,获取信息,在底部(权限),单击 + 符号并将 jenkins 添加到“用户和组”

于 2015-06-09T17:10:26.277 回答
0

在 Jenkins 中处理权限问题时需要检查的几件事:

  • 运行容器 (Tomcat) 或 Jenkins 本机二进制文件的用户名是什么?
  • jenkins 进程/jnlp/slave 使用什么用户名(如果这不在主 Jenkins 节点上)
于 2015-06-09T16:33:39.120 回答