在Jenkins中使用Packer在VMware工作站中调用虚拟机

时间:2018-12-12 07:25:27

标签: jenkins packer vmware-workstation

我的设置非常简单。在这里,我有一个Shell脚本,该脚本检查一些先决条件,然后启动Packer构建,在该Packer构建中,自定义Shell脚本作为预配程序运行。最近,我将其转移到詹金斯(Jenkins)的工作。但是当Packer触发构建时,它抛出以下错误:

 [1;32m==> vmware-iso: Building and writing VMX file [0m
 [1;32m==> vmware-iso: Starting HTTP server on port 8784 [0m
 [1;32m==> vmware-iso: Starting virtual machine... [0m
 [1;31m==> vmware-iso: Error starting VM: VMware error: Error: Cannot launch the UI because no display server is present in the current environment [0m
 [1;32m==> vmware-iso: Waiting 4.765878987s to give VMware time to clean up... [0m
 [1;32m==> vmware-iso: Deleting output directory... [0m
 [1;31mBuild 'vmware-iso' errored: Error starting VM: VMware error: Error: Cannot launch the UI because no display server is present in the current environment [0m

==> Some builds didn't complete successfully and had errors:
--> vmware-iso: Error starting VM: VMware error: Error: Cannot launch the UI because no display server is present in the current environment

==> Builds finished but no artifacts were created.

无法使用VMware工作站启动VM。 到目前为止已完成的工作:

  1. 广泛的谷歌搜索使我想到詹金斯应该拥有 启动UI应用程序的权限。
  2. 作为一种解决方法,我尝试在触发作业之前启动VMware工作站,但没有运气。此技巧可用于VirtualBox 但不适用于VMware工作站。

  3. 使用Jenkins搜索了与vmware相关的插件,但找不到任何插件。

请问有人指出我做错了什么,或者至少是一种解决办法吗?

2 个答案:

答案 0 :(得分:1)

首先请确保您拥有"headless": true。如果这还不够,则应使用X virtual framebuffer运行。

答案 1 :(得分:1)

可以通过为DISPLAY参数设置正确的值来解决UI问题。 在调用脚本之前添加此命令

  

export DISPLAY =本地主机:0.0