Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update org.jvnet.hudson.plugins from 1.346 -> 1.395 #14

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
7 changes: 6 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
If you're wanting to make changes, please clone the git repository at
This plugin integrates Jenkins with the VirtualBox 4.x virtual machine.

This is a clone of the virtualbox 3.x plugin
git://github.com/jenkinsci/virtualbox-plugin.git

... and fixes JENKINS-8634
"VirtualBox 4.0.2 web-server became incompatible with virtualbox plugin 0.2.1"
http://issues.jenkins-ci.org/browse/JENKINS-8634
4 changes: 2 additions & 2 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>virtualbox-parent</artifactId>
<version>0.3-SNAPSHOT</version>
<version>0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>virtualbox-client</artifactId>
<packaging>jar</packaging>
<name>Hudson VirtualBox Client</name>
<name>Jenkins VirtualBox Client</name>

<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/hudson/plugins/virtualbox/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void start() throws Exception {
Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
String url = dom.getElementsByTagName("url").item(0).getTextContent();

System.out.println("Hudson: " + url);
System.out.println("Jenkins: " + url);
hudson.remoting.Launcher.main("-jnlpUrl", getJnlp(url));
}

Expand Down
Binary file removed lib/org/virtualbox/vboxws/3.1/vboxws-3.1-java15.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws</artifactId>
<version>3.1</version>
<version>4.0</version>
<description>POM was created from install:install-file</description>
</project>
4 changes: 2 additions & 2 deletions lib/org/virtualbox/vboxws/maven-metadata-local.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<metadata>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws</artifactId>
<version>3.1</version>
<version>4.0</version>
<versioning>
<versions>
<version>3.1</version>
<version>4.0</version>
</versions>
<lastUpdated>20100416025301</lastUpdated>
</versioning>
Expand Down
12 changes: 6 additions & 6 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>virtualbox-parent</artifactId>
<version>0.3-SNAPSHOT</version>
<version>0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>virtualbox</artifactId>
<artifactId>virtualbox4</artifactId>
<packaging>hpi</packaging>
<name>Hudson VirtualBox Plugin</name>
<url>http://wiki.hudson-ci.org/display/HUDSON/VirtualBox+Plugin</url>
<name>Jenkins VirtualBox Plugin</name>
<url>http://wiki.jenkins-ci.org/display/JENKINS/VirtualBox+Plugin</url>

<dependencies>
<dependency>
<groupId>org.virtualbox</groupId>
<artifactId>vboxws</artifactId>
<version>3.1</version>
<classifier>java15</classifier>
<version>4.0</version>
<classifier>java16</classifier>
</dependency>
</dependencies>

Expand Down
92 changes: 51 additions & 41 deletions plugin/src/main/java/hudson/plugins/virtualbox/VirtualBoxUtils.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
package hudson.plugins.virtualbox;

import com.sun.xml.ws.commons.virtualbox_3_1.*;

import java.util.ArrayList;
import java.util.List;

import org.virtualbox_4_0.IMachine;
import org.virtualbox_4_0.IProgress;
import org.virtualbox_4_0.ISession;
import org.virtualbox_4_0.MachineState;
import org.virtualbox_4_0.VirtualBoxManager;

/**
* @author Evgeny Mandrikov
* @author Evgeny Mandrikov, Lars Gregori
*/
public final class VirtualBoxUtils {

private VirtualBoxUtils() {
}

static class ConnectionHolder {
IWebsessionManager manager;
IVirtualBox vbox;

public void disconnect() {
manager.disconnect(vbox);
}
}

private static ConnectionHolder connect(VirtualBoxCloud host) {
IWebsessionManager manager = new IWebsessionManager(host.getUrl());
ConnectionHolder holder = new ConnectionHolder();
holder.manager = manager;
holder.vbox = manager.logon(host.getUsername(), host.getPassword());
return holder;
private static VirtualBoxManager connect(VirtualBoxCloud host) {
VirtualBoxManager mgr = VirtualBoxManager.createInstance("Unter Null - The Failure Epiphany - You Have Fallen From Grace");
mgr.connect(host.getUrl(), host.getUsername(), host.getPassword());
return mgr;
}

/**
* Get virtual machines installed on specified host.
*
* @param host VirtualBox host
* @return list of virtual machines installed on specified host
*/
public static List<VirtualBoxMachine> getMachines(VirtualBoxCloud host) {
List<VirtualBoxMachine> result = new ArrayList<VirtualBoxMachine>();
ConnectionHolder holder = connect(host);
for (IMachine machine : holder.vbox.getMachines()) {
VirtualBoxManager mgr = connect(host);
for (IMachine machine : mgr.getVBox().getMachines()) {
result.add(new VirtualBoxMachine(host, machine.getName()));
}
holder.disconnect();
mgr.disconnect();
return result;
}

Expand All @@ -52,23 +47,31 @@ public static List<VirtualBoxMachine> getMachines(VirtualBoxCloud host) {
* @return result code
*/
public static long startVm(VirtualBoxMachine vbMachine, String type) {
ConnectionHolder holder = connect(vbMachine.getHost());
ISession session = holder.manager.getSessionObject(holder.vbox);
IMachine machine = holder.vbox.findMachine(vbMachine.getName());
VirtualBoxManager mgr = connect(vbMachine.getHost());
IMachine machine;
try {
machine = mgr.getVBox().findMachine(vbMachine.getName());
} catch (Exception e) {
try {
// try again ("idea" taken from VirtualBox 3.x example)
machine = mgr.getVBox().findMachine(vbMachine.getName());
} catch (Exception e2) {
return -1;
}
}

// check virtual machine state - if started, then do nothing
// TODO actually this should be in VirtualBoxComputerLauncher
if (org.virtualbox_3_1.MachineState.RUNNING == machine.getState()) {
if (MachineState.Running == machine.getState()) {
return 0;
}
IProgress progress = holder.vbox.openRemoteSession(
session,
machine.getId(),
type, // sessionType (headless, vrdp)
"" // env
);

ISession session = mgr.getSessionObject();
String env = "";
IProgress progress = machine.launchVMProcess(session, type, env);
progress.waitForCompletion(-1);
long result = progress.getResultCode();
holder.disconnect();
mgr.disconnect();
return result;
}

Expand All @@ -79,31 +82,38 @@ public static long startVm(VirtualBoxMachine vbMachine, String type) {
* @return result code
*/
public static long stopVm(VirtualBoxMachine vbMachine) {
ConnectionHolder holder = connect(vbMachine.getHost());
ISession session = holder.manager.getSessionObject(holder.vbox);
IMachine machine = holder.vbox.findMachine(vbMachine.getName());
VirtualBoxManager mgr = connect(vbMachine.getHost());
IMachine machine = mgr.getVBox().findMachine(vbMachine.getName());
// check virtual machine state - if not running, then do nothing
// TODO actually this should be in VirtualBoxComputerLauncher
if (org.virtualbox_3_1.MachineState.RUNNING != machine.getState()) {
if (MachineState.Running != machine.getState()) {
return 0;
}
holder.vbox.openExistingSession(session, machine.getId());
ISession session;
try {
session = mgr.openMachineSession(machine);
} catch (Exception e) {
return -1;
}

IProgress progress = session.getConsole().powerDown();
progress.waitForCompletion(-1);
long result = progress.getResultCode();
holder.disconnect();
mgr.disconnect();
return result;
}

/**
* MAC Address of specified virtual machine.
*
* @param vbMachine virtual machine
* @return MAC Address of specified virtual machine
*/
public static String getMacAddress(VirtualBoxMachine vbMachine) {
ConnectionHolder holder = connect(vbMachine.getHost());
IMachine machine = holder.vbox.findMachine(vbMachine.getName());
VirtualBoxManager mgr = connect(vbMachine.getHost());
IMachine machine = mgr.getVBox().findMachine(vbMachine.getName());
String macAddress = machine.getNetworkAdapter(0L).getMACAddress();
holder.disconnect();
mgr.disconnect();
return macAddress;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<f:entry title="${%VirtualBox Host}" field="hostName">
<select class="setting-input" name="hostName" value="${instance.hostName}"
onchange="updateListBox(document.getElementsByName('virtualMachineName')[0],'${rootURL}/plugin/virtualbox/computerNameValues?hostName='+encode(this.value))">
onchange="updateListBox(document.getElementsByName('virtualMachineName')[0],'${rootURL}/plugin/virtualbox4/computerNameValues?hostName='+encode(this.value))">
<option>Select host...</option>
<j:forEach var="d" items="${descriptor.hosts}">
<option selected="${d.displayName==it.hostName?'true':null}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<f:entry title="${%VirtualBox Host}" field="hostName">
<select class="setting-input" name="hostName" value="${it.hostName}"
onchange="updateListBox(document.getElementsByName('virtualMachineName')[0],'${rootURL}/plugin/virtualbox/computerNameValues?hostName='+encode(this.value))">
onchange="updateListBox(document.getElementsByName('virtualMachineName')[0],'${rootURL}/plugin/virtualbox4/computerNameValues?hostName='+encode(this.value))">
<option>Select host...</option>
<j:forEach var="d" items="${descriptor.hosts}">
<option selected="${d.displayName==it.hostName?'true':null}">
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
This plugin integrates Hudson with
This plugin integrates Jenkins with
<a href="http://www.virtualbox.org/">VirtualBox</a>
virtual machine.
</div>
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.346</version>
<version>1.395</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>virtualbox-parent</artifactId>
<packaging>pom</packaging>
<name>Hudson VirtualBox Parent</name>
<version>0.3-SNAPSHOT</version>
<name>Jenkins VirtualBox Parent</name>
<version>0.4-SNAPSHOT</version>

<developers>
<developer>
Expand Down
83 changes: 83 additions & 0 deletions pom.xml.versionsBackup
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.346</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>virtualbox-parent</artifactId>
<packaging>pom</packaging>
<name>Jenkins VirtualBox Parent</name>
<version>0.4-SNAPSHOT</version>

<developers>
<developer>
<id>godin</id>
<name>Evgeny Mandrikov</name>
<timezone>+3</timezone>
<roles>
<role>Developer</role>
</roles>
</developer>
</developers>

<modules>
<module>plugin</module>
<module>client</module>
</modules>

<scm>
<connection>scm:git:git://github.com/hudson/virtualbox-plugin.git</connection>
<developerConnection>scm:git:git://github.com/hudson/virtualbox-plugin.git</developerConnection>
<url>https://github.com/hudson/virtualbox-plugin</url>
</scm>
<distributionManagement>
<snapshotRepository>
<id>${snapshotRepositoryId}</id>
<url>${snapshotRepositoryUrl}</url>
</snapshotRepository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</build>
</project>