コード例 #1
0
  public void testNativeMaven() throws Exception {
    MavenInstallation maven = configureDefaultMaven();
    String mavenPath = maven.getHome();
    Jenkins.getInstance()
        .getDescriptorByType(Maven.DescriptorImpl.class)
        .setInstallations(new MavenInstallation("maven", "THIS IS WRONG", NO_PROPERTIES));

    MavenModuleSet project = createMavenProject();
    project.setScm(new ExtractResourceSCM(getClass().getResource("/simple-projects.zip")));
    project.setAssignedLabel(slave.getSelfLabel());
    project.setJDK(jenkins.getJDK("default"));

    project.setMaven("maven");
    project.setGoals("clean");

    Run build = project.scheduleBuild2(0).get();
    assertBuildStatus(Result.FAILURE, build);

    ToolLocationNodeProperty property =
        new ToolLocationNodeProperty(
            new ToolLocationNodeProperty.ToolLocation(
                jenkins.getDescriptorByType(MavenInstallation.DescriptorImpl.class),
                "maven",
                mavenPath));
    slave.getNodeProperties().add(property);

    build = project.scheduleBuild2(0).get();
    System.out.println(build.getLog());
    assertBuildStatus(Result.SUCCESS, build);
  }
コード例 #2
0
 public void setUp() throws Exception {
   super.setUp();
   EnvVars env = new EnvVars();
   // we don't want Maven, Ant, etc. to be discovered in the path for this test to work,
   // but on Unix these tools rely on other basic Unix tools (like env) for its operation,
   // so empty path breaks the test.
   env.put("PATH", "/bin:/usr/bin");
   env.put("M2_HOME", "empty");
   slave = createSlave(new LabelAtom("slave"), env);
   project = createFreeStyleProject();
   project.setAssignedLabel(slave.getSelfLabel());
 }
コード例 #3
0
 public void testCopyToSlave() throws Exception {
   DumbSlave node = createSlave();
   SlaveComputer c = node.getComputer();
   c.connect(false).get(); // wait until it's connected
   if (c.isOffline()) fail("Slave failed to go online: " + c.getLog());
   FreeStyleProject other = createArtifactProject(),
       p = createProject(other.getName(), "", "", false, false, false);
   assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause()).get());
   p.setAssignedLabel(node.getSelfLabel());
   FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get();
   assertBuildStatusSuccess(b);
   assertSame(node, b.getBuiltOn());
   assertFile(true, "foo.txt", b);
   assertFile(true, "subdir/subfoo.txt", b);
   assertFile(true, "deepfoo/a/b/c.log", b);
 }
コード例 #4
0
  @LocalData
  @Test
  public void slave() throws Exception {
    Assume.assumeFalse(
        "TimeoutException from basic",
        "https://jenkins.ci.cloudbees.com/job/core/job/jenkins_main_trunk/"
            .equals(System.getenv("JOB_URL")));
    DumbSlave s = j.createOnlineSlave();
    project.setAssignedLabel(s.getSelfLabel());

    FilePath src = new FilePath(j.jenkins.getRootPath(), "jobs/junit/workspace/");
    assertNotNull(src);
    FilePath dest = s.getWorkspaceFor(project);
    assertNotNull(dest);
    src.copyRecursiveTo("*.xml", dest);

    basic();
  }