forked from rtyler/vagrant-plugin
-
Notifications
You must be signed in to change notification settings - Fork 21
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,48 +1,50 @@ | |||
require 'rubygems' | require 'rubygems' | ||
require 'vagrant' | require 'vagrant' | ||
|
|
||
class VagrantWrapper < Jenkins::Tasks::BuildWrapper | module Vagrant | ||
display_name "Boot Vagrant box" | 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 path_to_vagrantfile(build) | ||
def initialize(attrs) | if @vagrantfile.nil? | ||
@vagrant = nil | return build.workspace.to_s | ||
@vagrantfile = attrs['vagrantfile'] | end | ||
end | |||
|
|
||
def path_to_vagrantfile(build) | return File.expand_path(File.join(build.workspace.to_s, @vagrantfile)) | ||
if @vagrantfile.nil? | |||
return build.workspace.to_s | |||
end | end | ||
|
|
||
return File.expand_path(File.join(build.workspace.to_s, @vagrantfile)) | # Called some time before the build is to start. | ||
end | def setup(build, launcher, listener) | ||
path = File.join(path_to_vagrantfile(build), 'Vagrantfile') | |||
|
|
||
# Called some time before the build is to start. | unless File.exists? path | ||
def setup(build, launcher, listener) | listener.info("There is no Vagrantfile in your workspace!") | ||
path = File.join(path_to_vagrantfile(build), 'Vagrantfile') | listener.info("We looked in: #{path}") | ||
build.native.setResult(Java.hudson.model.Result::NOT_BUILT) | |||
build.halt | |||
end | |||
|
|
||
unless File.exists? path | listener.info("Running Vagrant with version: #{Vagrant::VERSION}") | ||
listener.info("There is no Vagrantfile in your workspace!") | @vagrant = Vagrant::Environment.new(:cwd => path) | ||
listener.info("We looked in: #{path}") | listener.info "Vagrantfile loaded, bringing Vagrant box up for the build" | ||
build.native.setResult(Java.hudson.model.Result::NOT_BUILT) | @vagrant.cli('up', '--no-provision') | ||
build.halt | listener.info "Vagrant box is online, continuing with the build" | ||
end | |||
|
|
||
listener.info("Running Vagrant with version: #{Vagrant::VERSION}") | build.env[:vagrant] = @vagrant | ||
@vagrant = Vagrant::Environment.new(:cwd => path) | end | ||
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 | |||
|
|
||
# Called some time when the build is finished. | # Called some time when the build is finished. | ||
def teardown(build, listener) | def teardown(build, listener) | ||
listener.info "Build finished, destroying the Vagrant box" | listener.info "Build finished, destroying the Vagrant box" | ||
unless @vagrant.nil? | unless @vagrant.nil? | ||
@vagrant.cli('destroy', '-f') | @vagrant.cli('destroy', '-f') | ||
end | |||
end | end | ||
end | end | ||
end | end |
File renamed without changes.
File renamed without changes.
File renamed without changes.