forked from rtyler/vagrant-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename the crap out of all these classes
Part of this is to make things a bit cleaner, the other part is to fix the BaseVagrantBuilder showing up as a build step, derp
- Loading branch information
R. Tyler Croy
committed
Mar 13, 2012
1 parent
d3f90a8
commit 2bba59f
Showing
5 changed files
with
107 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,50 @@ | ||
require 'rubygems' | ||
require 'vagrant' | ||
|
||
class VagrantWrapper < Jenkins::Tasks::BuildWrapper | ||
display_name "Boot Vagrant box" | ||
module Vagrant | ||
class BasicWrapper < Jenkins::Tasks::BuildWrapper | ||
display_name "Boot Vagrant box" | ||
|
||
attr_accessor :vagrantfile | ||
def initialize(attrs) | ||
@vagrant = nil | ||
@vagrantfile = attrs['vagrantfile'] | ||
end | ||
|
||
attr_accessor :vagrantfile | ||
def initialize(attrs) | ||
@vagrant = nil | ||
@vagrantfile = attrs['vagrantfile'] | ||
end | ||
def path_to_vagrantfile(build) | ||
if @vagrantfile.nil? | ||
return build.workspace.to_s | ||
end | ||
|
||
def path_to_vagrantfile(build) | ||
if @vagrantfile.nil? | ||
return build.workspace.to_s | ||
return File.expand_path(File.join(build.workspace.to_s, @vagrantfile)) | ||
end | ||
|
||
return File.expand_path(File.join(build.workspace.to_s, @vagrantfile)) | ||
end | ||
# Called some time before the build is to start. | ||
def setup(build, launcher, listener) | ||
path = File.join(path_to_vagrantfile(build), 'Vagrantfile') | ||
|
||
# Called some time before the build is to start. | ||
def setup(build, launcher, listener) | ||
path = File.join(path_to_vagrantfile(build), 'Vagrantfile') | ||
unless File.exists? path | ||
listener.info("There is no Vagrantfile in your workspace!") | ||
listener.info("We looked in: #{path}") | ||
build.native.setResult(Java.hudson.model.Result::NOT_BUILT) | ||
build.halt | ||
end | ||
|
||
unless File.exists? path | ||
listener.info("There is no Vagrantfile in your workspace!") | ||
listener.info("We looked in: #{path}") | ||
build.native.setResult(Java.hudson.model.Result::NOT_BUILT) | ||
build.halt | ||
end | ||
listener.info("Running Vagrant with version: #{Vagrant::VERSION}") | ||
@vagrant = Vagrant::Environment.new(:cwd => path) | ||
listener.info "Vagrantfile loaded, bringing Vagrant box up for the build" | ||
@vagrant.cli('up', '--no-provision') | ||
listener.info "Vagrant box is online, continuing with the build" | ||
|
||
listener.info("Running Vagrant with version: #{Vagrant::VERSION}") | ||
@vagrant = Vagrant::Environment.new(:cwd => path) | ||
listener.info "Vagrantfile loaded, bringing Vagrant box up for the build" | ||
@vagrant.cli('up', '--no-provision') | ||
listener.info "Vagrant box is online, continuing with the build" | ||
|
||
build.env[:vagrant] = @vagrant | ||
end | ||
build.env[:vagrant] = @vagrant | ||
end | ||
|
||
# Called some time when the build is finished. | ||
def teardown(build, listener) | ||
listener.info "Build finished, destroying the Vagrant box" | ||
unless @vagrant.nil? | ||
@vagrant.cli('destroy', '-f') | ||
# Called some time when the build is finished. | ||
def teardown(build, listener) | ||
listener.info "Build finished, destroying the Vagrant box" | ||
unless @vagrant.nil? | ||
@vagrant.cli('destroy', '-f') | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.