Exemplo n.º 1
0
  /** Fake installation on Unix. */
  @Test
  public void fakeUnixInstall() throws Exception {
    Assume.assumeFalse("If we're on Windows, don't bother doing this", Functions.isWindows());

    File bundle = File.createTempFile("fake-jdk-by-hudson", "sh");
    try {
      new FilePath(bundle)
          .write(
              "#!/bin/bash -ex\n"
                  + "mkdir -p jdk1.6.0_dummy/bin\n"
                  + "touch jdk1.6.0_dummy/bin/java",
              "ASCII");
      TaskListener l = StreamTaskListener.fromStdout();

      new JDKInstaller("", true)
          .install(
              new LocalLauncher(l),
              Platform.LINUX,
              new JDKInstaller.FilePathFileSystem(j.jenkins),
              l,
              tmp.getRoot().getPath(),
              bundle.getPath());

      assertTrue(new File(tmp.getRoot(), "bin/java").exists());
    } finally {
      bundle.delete();
    }
  }
        @Override
        public void before() throws Throwable {
          super.before();

          content = new JellyScriptContent();
          listener = StreamTaskListener.fromStdout();

          publisher = new ExtendedEmailPublisher();
          publisher.defaultContent =
              "For only 10 easy payment of $69.99 , AWESOME-O 4000 can be yours!";
          publisher.defaultSubject = "How would you like your very own AWESOME-O 4000?";
          publisher.recipientList = "*****@*****.**";

          Field f = ExtendedEmailPublisherDescriptor.class.getDeclaredField("defaultBody");
          f.setAccessible(true);
          f.set(publisher.getDescriptor(), "Give me $4000 and I'll mail you a check for $40,000!");
          f = ExtendedEmailPublisherDescriptor.class.getDeclaredField("defaultSubject");
          f.setAccessible(true);
          f.set(publisher.getDescriptor(), "Nigerian needs your help!");

          f = ExtendedEmailPublisherDescriptor.class.getDeclaredField("recipientList");
          f.setAccessible(true);
          f.set(publisher.getDescriptor(), "*****@*****.**");

          f = ExtendedEmailPublisherDescriptor.class.getDeclaredField("hudsonUrl");
          f.setAccessible(true);
          f.set(publisher.getDescriptor(), "http://localhost/");

          build = mock(AbstractBuild.class);
          AbstractProject project = mock(AbstractProject.class);
          DescribableList publishers = mock(DescribableList.class);
          when(publishers.get(ExtendedEmailPublisher.class)).thenReturn(publisher);
          when(project.getPublishersList()).thenReturn(publishers);
          when(build.getProject()).thenReturn(project);
        }
Exemplo n.º 3
0
  /** Can we locate the bundles? */
  @Test
  public void locate() throws Exception {
    Assume.assumeTrue(
        "this is a really time consuming test, so only run it when we really want",
        Boolean.getBoolean("jenkins.testJDKInstaller"));

    retrieveUpdateCenterData();

    JDKInstaller i = new JDKInstaller("jdk-7u3-oth-JPR", true);
    StreamTaskListener listener = StreamTaskListener.fromStdout();
    i.locate(listener, Platform.LINUX, CPU.i386);
    i.locate(listener, Platform.WINDOWS, CPU.amd64);
    i.locate(listener, Platform.SOLARIS, CPU.Sparc);
  }
  public BuildActionResultsDisplay getBuildActionResultsDisplay() {
    BuildActionResultsDisplay buildDisplay = null;
    WeakReference<BuildActionResultsDisplay> wr = this.buildActionResultsDisplay;
    if (wr != null) {
      buildDisplay = wr.get();
      if (buildDisplay != null) return buildDisplay;
    }

    try {
      buildDisplay = new BuildActionResultsDisplay(this, StreamTaskListener.fromStdout());
    } catch (IOException e) {
      logger.log(Level.SEVERE, "Error creating new BuildActionResultsDisplay()", e);
    }
    this.buildActionResultsDisplay = new WeakReference<BuildActionResultsDisplay>(buildDisplay);
    return buildDisplay;
  }
 @Override
 public boolean processWorkspaceBeforeDeletion(
     AbstractProject<?, ?> project, FilePath workspace, Node node)
     throws IOException, InterruptedException {
   if (node == null) {
     // HUDSON-7663 : deleting a job that has never run
     return true;
   }
   StreamTaskListener listener = StreamTaskListener.fromStdout();
   Launcher launcher = node.createLauncher(listener);
   ClearTool ct =
       createClearTool(
           null,
           createClearToolLauncher(
               listener, project.getSomeWorkspace().getParent().getParent(), launcher));
   try {
     if (isUseDynamicView() && !isCreateDynView()) {
       return true;
     }
     AbstractBuild<?, ?> latestBuildOnNode = null;
     for (AbstractBuild<?, ?> build : project.getBuilds()) {
       if (node.equals(build.getBuiltOn())) {
         latestBuildOnNode = build;
         break;
       }
     }
     if (latestBuildOnNode == null) {
       latestBuildOnNode = project.getLastBuild();
     }
     BuildVariableResolver buildVariableResolver = new BuildVariableResolver(latestBuildOnNode);
     ct.rmviewtag(generateNormalizedViewName(buildVariableResolver));
   } catch (Exception e) {
     Logger.getLogger(AbstractClearCaseScm.class.getName())
         .log(Level.WARNING, "Failed to remove ClearCase view", e);
   }
   return true;
 }