Class JenkinsController

java.lang.Object
org.jenkinsci.test.acceptance.controller.JenkinsController
All Implemented Interfaces:
Closeable, AutoCloseable, IJenkinsController, AutoCleaned
Direct Known Subclasses:
ExistingJenkinsController, LocalController, PooledJenkinsController

public abstract class JenkinsController extends Object implements IJenkinsController, AutoCleaned
Starts/stops Jenkins and exposes where it is running.

This abstracts away how the test harness launches Jenkins-under-test and where, which is determined at runtime by the user who runs the tests, not by the author of tests.

Author:
Vivek Pandey
  • Field Details

    • isQuite

      @Inject @Named("quite") protected boolean isQuite
    • WORKSPACE

      @Inject @Named("WORKSPACE") protected String WORKSPACE
    • STARTUP_TIMEOUT

      public static final int STARTUP_TIMEOUT
    • injector

      public com.google.inject.Injector injector
  • Constructor Details

    • JenkinsController

      protected JenkinsController(com.google.inject.Injector i)
  • Method Details

    • postConstruct

      public void postConstruct(com.google.inject.Injector injector)
      Called when JenkinsController is pulled into a world prior to start()
    • start

      public void start() throws IOException
      Starts Jenkins.
      Specified by:
      start in interface IJenkinsController
      Throws:
      IOException
    • startNow

      public abstract void startNow() throws IOException
      Synchronously start Jenkins instance until it starts responding to the specified URL.
      Throws:
      IOException
    • stop

      public void stop() throws IOException
      Stops Jenkins
      Specified by:
      stop in interface IJenkinsController
      Throws:
      IOException
    • getLogPrinter

      protected LogListener getLogPrinter()
    • stopNow

      public abstract void stopNow() throws IOException
      Synchronously shutdown Jenkins instance.

      This method must leave JENKINS_HOME intact so that it can be started later. To really delete the data and clean up, see tearDown().

      Throws:
      IOException
    • close

      public final void close() throws IOException
      Alias for tearDown().
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • tearDown

      public abstract void tearDown() throws IOException
      Assuming the instance had already stopped, destroy JENKINS_HOME and release resources used by Jenkins.
      Throws:
      IOException
    • restart

      public void restart() throws IOException
      Stops and starts running Jenkins to perform a full JVM restart.
      Throws:
      IOException
    • isRunning

      public boolean isRunning()
    • getUrl

      public abstract URL getUrl()
      Gives URL where Jenkins is listening. Must end with "/"
      Specified by:
      getUrl in interface IJenkinsController
    • getInitialCredentials

      @CheckForNull public org.apache.http.auth.Credentials getInitialCredentials()
    • getLogId

      public String getLogId()
      Returns the short ID used to prefix log output from the process into the test.
    • diagnose

      public void diagnose(Throwable cause) throws IOException
      Perform controller specific diagnostics for test failure. Defaults to no-op.
      Parameters:
      cause - Failure cause
      Throws:
      IOException