Merge pull request #21 from darthsteven/master

Implement locking to prevent import errors
This commit is contained in:
R. Tyler Croy 2012-12-29 13:03:58 -08:00
commit 126e070108
2 changed files with 9 additions and 1 deletions

View File

@ -5,6 +5,7 @@ gem "jenkins-plugin", '~> 0.2.0'
#gem "vagrant", '~> 1.0.1'
gem 'vagrant', :git => 'git://github.com/rtyler/vagrant', :ref => '8a5b1ad'
gem 'jruby-openssl'
gem 'lockfile'
group :development do
gem 'jpi', '~> 0.3.3'

View File

@ -1,5 +1,7 @@
require 'rubygems'
require 'vagrant'
require 'lockfile'
require 'tmpdir'
module Vagrant
# This will handle proxying output from Vagrant into Jenkins
@ -64,7 +66,12 @@ module Vagrant
@vagrant.ui.listener = listener
listener.info "Vagrantfile loaded, bringing Vagrant box up for the build"
@vagrant.cli('up', '--no-provision')
# Vagrant doesn't currently implement any locking, neither does
# VBoxManage, and it will fail if importing two boxes concurrently, so use
# a file lock to make sure that doesn't happen.
Lockfile.new(File.join(Dir.tmpdir, ".vagrant-jenkins-plugin.lock")) do
@vagrant.cli('up', '--no-provision')
end
listener.info "Vagrant box is online, continuing with the build"
build.env[:vagrant] = @vagrant