Issue Type: Bug Bug
Assignee: Daniel Spilker
Components: gradle-jpi-plugin
Created: 08/Apr/15 1:41 AM
Description:

I get the following error when trying to run a unit test. Example code is below.

I was able to get past this error by including dependancy testCompile 'org.jvnet.hudson.main:hudson-core:1.159' but that then said other classes where missing. This doesn't see the correct path to go down anyway.

Error

 
java.lang.NoClassDefFoundError: hudson/matrix/MatrixRun
	at com.inedo.TriggerBuildStepTest.<init>(TriggerBuildStepTest.java:13)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
...
Caused by: java.lang.ClassNotFoundException: hudson.matrix.MatrixRun
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 23 more

Code Example

package test.example;

import static org.junit.Assert.*;
import org.jvnet.hudson.test.JenkinsRule;
import org.apache.commons.io.FileUtils;
import hudson.model.*;
import hudson.tasks.Shell;
import org.junit.Test;
import org.junit.Rule;

public class TriggerBuildStepTest {
  @Rule 
  public JenkinsRule j = new JenkinsRule();
  
  @Test 
  public void first() throws Exception {

    FreeStyleProject project = j.createFreeStyleProject();
    project.getBuildersList().add(new Shell("echo hello"));
    FreeStyleBuild build = project.scheduleBuild2(0).get();
    System.out.println(build.getDisplayName() + " completed");
    
    // TODO: change this to use HtmlUnit
    String s = FileUtils.readFileToString(build.getLogFile());
    assertTrue(s.contains("+ echo hello"));
  }
}
Environment: dependencies {
    classpath 'org.jenkins-ci.tools:gradle-jpi-plugin:0.10.2'
}
Project: Jenkins
Priority: Minor Minor
Reporter: Andrew Sumner
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to