Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
1473e05
updated maven pom to use repo.jenkins-ci.org repository
ndeloof Apr 6, 2012
2038260
Add VirtualBox 4.2 Controller
hgomez Sep 15, 2012
65b70ed
Add VirtualBox 4.2 ws
hgomez Sep 15, 2012
caf0967
Merge pull request #2 from hgomez/master
hgomez Sep 18, 2012
09eef15
Add link to wiki page
hgomez Sep 18, 2012
62ad43e
Add myself in developpers list to follow Jenkins precos
hgomez Sep 21, 2012
c2eba85
fix release plugin version
olamy Sep 21, 2012
d4771c1
dependencies not needed
olamy Sep 21, 2012
12d71c3
upgrade parent pom
olamy Sep 21, 2012
1d9bb30
Add markdown
hgomez Sep 21, 2012
15112d4
update md
hgomez Sep 21, 2012
8a0bdc7
update
hgomez Sep 21, 2012
3bc5937
update
hgomez Sep 21, 2012
692d68c
turn scm for developpers from https to ssh
hgomez Sep 21, 2012
1cf3983
fix scm loc
hgomez Sep 21, 2012
faa5dd1
[maven-release-plugin] prepare release virtualbox-parent-0.5
hgomez Sep 21, 2012
2063732
[maven-release-plugin] prepare for next development iteration
hgomez Sep 21, 2012
d5870a3
dist management inherited from parent
olamy Sep 21, 2012
4b6df87
Add stop mode to VirtualBox slaves
hgomez Oct 7, 2012
d0cb7d6
use powerdown instead of stop
hgomez Oct 7, 2012
78211ca
correct desc
hgomez Oct 7, 2012
e21ab7b
ensure backward compat
hgomez Oct 7, 2012
9521baf
revert, only one DataBound
hgomez Oct 7, 2012
215e518
[maven-release-plugin] prepare release virtualbox-parent-0.6
hgomez Oct 7, 2012
173d234
[maven-release-plugin] prepare for next development iteration
hgomez Oct 7, 2012
4372859
add backward compatible constructor
hgomez Oct 7, 2012
2e14a66
Proof of conept: Restore to snapshot after every build
bb-froggy Mar 17, 2013
2afe6e2
Add: start script
Jul 30, 2013
fc5cec8
Merge 4.2-support to snap-branch
Jul 31, 2013
93aed5e
Merge branch 'master' into snap
Jul 31, 2013
8361492
Fix merge-misstake
Jul 31, 2013
c0199dd
Add support for 4.2 Snapshot
Aug 1, 2013
02a46e7
remove duplicate code
Aug 1, 2013
5fcad35
Fix startscript
Aug 13, 2013
ffed15a
add VirtualBox 4.3.0 Soap stubs
hgomez Oct 16, 2013
fbc0c42
VirtualBox 4.3 control
hgomez Oct 16, 2013
6a67c8d
update to VirtualBox 4.3 APIs
hgomez Oct 21, 2013
574e8fb
update poms
hgomez Oct 21, 2013
db5221a
merge branches
hgomez Oct 21, 2013
85d8263
Add back VBox 4.3
hgomez Oct 21, 2013
0ee8dd2
Merge pull request #3 from hgomez/master
hgomez Oct 21, 2013
2c24fa0
Update VBox 4.3 Control
hgomez Oct 21, 2013
ca6b195
Merge pull request #4 from hgomez/master
hgomez Oct 21, 2013
aa757a9
Source format and deleting unnecessary @SuppressWarnings
Oct 21, 2013
d57f25b
Avoid code duplication
Oct 21, 2013
a3a219b
Passing informations from Slave to ComputerLauncher
Oct 21, 2013
73bc19d
[maven-release-plugin] prepare release virtualbox-parent-0.7
hgomez Oct 21, 2013
9378385
[maven-release-plugin] prepare for next development iteration
hgomez Oct 21, 2013
fcb0803
Merge branch 'master' of [email protected]:jenkinsci/virtualbox-plugin.git
Oct 24, 2013
eaec184
Merge pull request #5 from netceler/master
hgomez Oct 24, 2013
fc4b1ab
Merge branch 'master' into snap
Dec 24, 2013
e7e774c
Merge remote-tracking branch 'Oscarlsson/snap'
Dec 24, 2013
21aa8f4
Port snapshot handling changes to virtualbox v4.3
Dec 24, 2013
b08e8bf
Merge remote-tracking branch 'parent/snap'
Dec 24, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
VirtualBox Plugin
=================

This plugin manage slaves using VirtualBox vms with its WebServer API.

Sources
-------

If you're wanting to make changes, please clone the git repository at [sources]

git://github.com/jenkinsci/virtualbox-plugin.git

Documentation
-------------

Plugin Wiki page [wikipage]


[ButlerImage]: http://jenkins-ci.org/sites/default/files/jenkins_logo.png
[website]: http://jenkins-ci.org
[wikipage]: https://wiki.jenkins-ci.org/display/JENKINS/VirtualBox+Plugin
[sources]: https://github.com/jenkinsci/virtualbox-plugin

29 changes: 3 additions & 26 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
This is an experimental branch for Virtualbox Snapshot testing.
git://github.com/jenkinsci/virtualbox-plugin.git

Wiki page at

If you create a snapshot in a virtual machine this snapshot will be listed in the Jenkins node configuration at the Virtual Machine Name as <machineName>//<Snapshot>. It is also possible to create snapshot trees. In this case the Virtual Machine Name is build as <machineName>//<Snapshot>/<Snapshot2>.

When the virtualbox-plugin starts and stops the virtual machine the selected snapshot is restored. This allows you to setup a virtual machine in a defined statewith e.g. test data.

Note: An error will be caused, if the virtual machine is relaunched while it already runs. Therefore the virtual machine has to be stopped (maybe the plugin can do this in one of the next releases). To avoid this, set the Availability in the Jenkins node configuration to 'Take this slave on-line when in demand and off-line when idle', 'In demand delay' and 'Idle delay' to 1, and add a label which is also used for the build job definition. Jenkins will start the virtual machine when the build job is started and stops the virtual machine (the plugin will also restore the virtual machine).


Note: Snapshots are implemented for Virtualbox 4.0 and 4.1. Version 3.x isn't supported (at the moment).


----

Some 'git stuff' for this branch:


git clone https://github.com/jenkinsci/virtualbox-plugin.git
## or git pull

git branch -r
## shows remote branch origin/snap

git branch --track snap origin/snap
## tracks the (see also ################################################################################)

git checkout snap
https://wiki.jenkins-ci.org/display/JENKINS/VirtualBox+Plugin
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>virtualbox-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
23 changes: 23 additions & 0 deletions lib/org/virtualbox/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,26 @@ mvn deploy:deploy-file
-Dfile=/PATH_TO_DOWNLOADED_JAR/vboxjws-4.1.8.jar
-Durl=file:/PATH_TO_PLUGIN_SOURCES/virtualbox-plugin/plugin/../lib
-DrepositoryId=virtualbox-libs


Command used to install vboxws.jar version 4.2.0 to local repository:

mvn deploy:deploy-file
-DgroupId=org.virtualbox
-DartifactId=vboxws-42
-Dversion=4.2.0
-Dpackaging=jar
-Dfile=/PATH_TO_DOWNLOADED_JAR/vboxjws-4.2.0.jar
-Durl=file:/PATH_TO_PLUGIN_SOURCES/virtualbox-plugin/plugin/../lib
-DrepositoryId=virtualbox-libs

Command used to install vboxws.jar version 4.3.0 to local repository:

mvn deploy:deploy-file
-DgroupId=org.virtualbox
-DartifactId=vboxws-43
-Dversion=4.3.0
-Dpackaging=jar
-Dfile=/PATH_TO_DOWNLOADED_JAR/vboxjws-4.3.0.jar
-Durl=file:/PATH_TO_PLUGIN_SOURCES/virtualbox-plugin/plugin/../lib
-DrepositoryId=virtualbox-libs
Binary file not shown.
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-42/4.2.0/vboxws-42-4.2.0.jar.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c884629596f4eda162c9f412dadd8321
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24ba74a8b017e479a24cf0a695ec6442be519798
8 changes: 8 additions & 0 deletions lib/org/virtualbox/vboxws-42/4.2.0/vboxws-42-4.2.0.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-42</artifactId>
<version>4.2.0</version>
</project>
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-42/4.2.0/vboxws-42-4.2.0.pom.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d26aa718e5d01f71fa916af6d7c21b65
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3dbb8214e83dd58e45a3443c9fab94de3695bc24
12 changes: 12 additions & 0 deletions lib/org/virtualbox/vboxws-42/maven-metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-42</artifactId>
<versioning>
<release>4.2.0</release>
<versions>
<version>4.2.0</version>
</versions>
<lastUpdated>20120915115604</lastUpdated>
</versioning>
</metadata>
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-42/maven-metadata.xml.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
799bb16aba4aff40834def6e0933815d
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-42/maven-metadata.xml.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d347676b8b35c43bf53f7321e4f19f9ce2f95577
Binary file not shown.
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-43/4.3.0/vboxws-43-4.3.0.jar.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
589d48ae7b4d7e981164ad6de80d456b
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4639673004fadf186fa033e01ca662923221d4b0
8 changes: 8 additions & 0 deletions lib/org/virtualbox/vboxws-43/4.3.0/vboxws-43-4.3.0.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-43</artifactId>
<version>4.3.0</version>
</project>
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-43/4.3.0/vboxws-43-4.3.0.pom.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8469c434998c1edead34ab7a44dca8f5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
55747744528d742cefb6b4f623f81220e042f6df
12 changes: 12 additions & 0 deletions lib/org/virtualbox/vboxws-43/maven-metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-43</artifactId>
<versioning>
<release>4.3.0</release>
<versions>
<version>4.3.0</version>
</versions>
<lastUpdated>20131016142905</lastUpdated>
</versioning>
</metadata>
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-43/maven-metadata.xml.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f99be82d08cfba9f59c01be24819ecd8
1 change: 1 addition & 0 deletions lib/org/virtualbox/vboxws-43/maven-metadata.xml.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c69fe4411a3198e238e3252fd65c9e55438b812b
22 changes: 16 additions & 6 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>virtualbox-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -26,11 +26,21 @@
<artifactId>vboxws-40</artifactId>
<version>4.0.8</version>
</dependency>
<dependency>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-41</artifactId>
<version>4.1.8</version>
</dependency>
<dependency>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-41</artifactId>
<version>4.1.8</version>
</dependency>
<dependency>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-42</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws-43</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EnvironmentImpl extends Environment {
public boolean tearDown(AbstractBuild build, BuildListener listener) throws IOException, InterruptedException {
VirtualBoxMachine machine = VirtualBoxPlugin.getVirtualBoxMachine(getHostName(), getVirtualMachineName());
listener.getLogger().println(Messages.VirtualBoxLauncher_stopVM(machine));
VirtualBoxUtils.stopVm(machine, new VirtualBoxTaskListenerLog(listener, "[VirtualBox] "));
VirtualBoxUtils.stopVm(machine, "pause", new VirtualBoxTaskListenerLog(listener, "[VirtualBox] "));
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package hudson.plugins.virtualbox;

import org.kohsuke.stapler.DataBoundConstructor;

import hudson.model.Descriptor;
import hudson.model.TaskListener;
import hudson.slaves.ComputerLauncher;
import hudson.slaves.SlaveComputer;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -24,26 +27,36 @@ public class VirtualBoxComputerLauncher extends ComputerLauncher {

private ComputerLauncher delegate;

/**
* @param delegate real user-specified {@link ComputerLauncher}.
*/
public VirtualBoxComputerLauncher(ComputerLauncher delegate) {
private String hostName;

private String virtualMachineName;

private String virtualMachineType;

private String virtualMachineStopMode;

@DataBoundConstructor
public VirtualBoxComputerLauncher(ComputerLauncher delegate, String hostName, String virtualMachineName,
String virtualMachineType, String virtualMachineStopMode) {
this.delegate = delegate;
this.hostName = hostName;
this.virtualMachineName = virtualMachineName;
this.virtualMachineType = virtualMachineType;
this.virtualMachineStopMode = virtualMachineStopMode;
}

@Override
public void launch(SlaveComputer computer, TaskListener listener) throws IOException, InterruptedException {
VirtualBoxSlave slave = ((VirtualBoxComputer) computer).getNode();
log(listener, "Launching node " + slave.getVirtualMachineName());
log(listener, "Launching node " + virtualMachineName);
try {
// Connect to VirtualBox host
VirtualBoxMachine machine = VirtualBoxPlugin.getVirtualBoxMachine(slave.getHostName(), slave.getVirtualMachineName());
VirtualBoxMachine machine = VirtualBoxPlugin.getVirtualBoxMachine(hostName, virtualMachineName);
if (machine == null) {
listener.fatalError("Unable to find specified machine");
return;
}
log(listener, Messages.VirtualBoxLauncher_startVM(machine));
long result = VirtualBoxUtils.startVm(machine, slave.getVirtualMachineType(), new VirtualBoxTaskListenerLog(listener, "[VirtualBox] "));
long result = VirtualBoxUtils.startVm(machine, virtualMachineType, new VirtualBoxTaskListenerLog(listener, "[VirtualBox] "));
if (result != 0) {
listener.fatalError("Unable to launch");
return;
Expand Down Expand Up @@ -102,20 +115,19 @@ public void beforeDisconnect(SlaveComputer computer, TaskListener listener) {

@Override
public void afterDisconnect(SlaveComputer computer, TaskListener listener) {
VirtualBoxSlave slave = ((VirtualBoxComputer) computer).getNode();
// Stage 2 of the afterDisconnect
log(listener, "Starting stage 2 afterDisconnect");
getCore().afterDisconnect(computer, listener);
log(listener, "Stage 2 afterDisconnect completed");

try {
// Connect to VirtualBox host
VirtualBoxMachine machine = VirtualBoxPlugin.getVirtualBoxMachine(slave.getHostName(), slave.getVirtualMachineName());
VirtualBoxMachine machine = VirtualBoxPlugin.getVirtualBoxMachine(hostName, virtualMachineName);
if (machine == null) {
listener.fatalError("Unable to find specified machine");
}
log(listener, Messages.VirtualBoxLauncher_stopVM(machine));
long result = VirtualBoxUtils.stopVm(machine, new VirtualBoxTaskListenerLog(listener, "[VirtualBox] "));
long result = VirtualBoxUtils.stopVm(machine, virtualMachineStopMode, new VirtualBoxTaskListenerLog(listener, "[VirtualBox] "));
if (result != 0) {
listener.fatalError("Unable to stop");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
public interface VirtualBoxControl {
public long startVm(VirtualBoxMachine machine, String virtualMachineType, VirtualBoxLogger log);
public long stopVm(VirtualBoxMachine machine, VirtualBoxLogger log);
public long stopVm(VirtualBoxMachine machine, String virtualMachineStopMode, VirtualBoxLogger log);

public List<VirtualBoxMachine> getMachines(VirtualBoxCloud host, VirtualBoxLogger log);
public String getMacAddress(VirtualBoxMachine machine, VirtualBoxLogger log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public synchronized long startVm(VirtualBoxMachine vbMachine, String type, Virtu
* @param vbMachine virtual machine to stop
* @return result code
*/
public synchronized long stopVm(VirtualBoxMachine vbMachine, VirtualBoxLogger log) {
public synchronized long stopVm(VirtualBoxMachine vbMachine, String stopMode, VirtualBoxLogger log) {
ConnectionHolder holder = connect(hostUrl, userName, password);
IMachine machine = holder.vbox.findMachine(vbMachine.getName());
if (org.virtualbox_3_1.MachineState.RUNNING != machine.getState()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public synchronized long startVm(VirtualBoxMachine vbMachine, String type, Virtu
* @param log
* @return result code
*/
public synchronized long stopVm(VirtualBoxMachine vbMachine, VirtualBoxLogger log) {
public synchronized long stopVm(VirtualBoxMachine vbMachine, String stopMode, VirtualBoxLogger log) {
String machineName = vbMachine.getName();
String machineId = vbMachine.getMachineId();
String snapshotId = vbMachine.getSnapshotId();
Expand Down Expand Up @@ -252,7 +252,7 @@ public synchronized long stopVm(VirtualBoxMachine vbMachine, VirtualBoxLogger lo
return -1;
}

if (MachineState.Stuck == state) {
if (MachineState.Stuck == state || "powerdown".equals(stopMode)) {
// for Stuck state call powerDown and go to PoweredOff state
progress = session.getConsole().powerDown();
} else if (snapshot != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public synchronized long startVm(VirtualBoxMachine vbMachine, String type, Virtu
* @param log
* @return result code
*/
public synchronized long stopVm(VirtualBoxMachine vbMachine, VirtualBoxLogger log) {
public synchronized long stopVm(VirtualBoxMachine vbMachine, String stopMode, VirtualBoxLogger log) {
String machineName = vbMachine.getName();
String machineId = vbMachine.getMachineId();
String snapshotId = vbMachine.getSnapshotId();
Expand Down Expand Up @@ -252,7 +252,7 @@ public synchronized long stopVm(VirtualBoxMachine vbMachine, VirtualBoxLogger lo
return -1;
}

if (MachineState.Stuck == state) {
if (MachineState.Stuck == state || "powerdown".equals(stopMode)) {
// for Stuck state call powerDown and go to PoweredOff state
progress = session.getConsole().powerDown();
} else if (snapshot != null) {
Expand Down
Loading