All Implemented Interfaces:
CapybaraPortingLayer
Direct Known Subclasses:
FreeStyleJob, FreeStyleMultiBranchJob, MatrixConfiguration, MatrixProject, MavenModule, MavenModuleSet, WorkflowJob

public class Job extends TopLevelItem
Job Page object superclass. As with other TopLevelItems, use Describable annotation to register an implementation.
Author:
Kohsuke Kawaguchi
  • Field Details

    • controller

      @Inject public JenkinsController controller
      The controller that starts/stops Jenkins
    • publishers

      protected List<PostBuildStep> publishers
    • concurrentBuild

      public final Control concurrentBuild
  • Constructor Details

    • Job

      public Job(com.google.inject.Injector injector, URL url, String name)
    • Job

      public Job(PageObject context, URL url, String name)
  • Method Details

    • getParameters

      public List<Parameter> getParameters()
      Overrides:
      getParameters in class TopLevelItem
    • useScm

      public <T extends Scm> T useScm(Class<T> type)
    • addPreBuildStep

      public <T extends BuildStep> T addPreBuildStep(Class<T> type)
    • addBuildStep

      public <T extends BuildStep> T addBuildStep(Class<T> type)
    • removeFirstBuildStep

      public void removeFirstBuildStep()
    • addPublisher

      public <T extends PostBuildStep> T addPublisher(Class<T> publisherClass)
      Adds the specified publisher to this job. Publishers are stored in a list member to provide later access for modification.
      Type Parameters:
      T - the type of the publisher
      Parameters:
      publisherClass - the publisher to configure
      See Also:
    • addPublisher

      public <T extends PostBuildStep> T addPublisher(Class<T> type, Consumer<T> configuration)
      Adds the specified publisher to this job. Publishers are stored in a list member to provide later access for modification. After the publisher has been added the publisher is configured with the specified configuration lambda. Afterwards, the job configuration page still is visible and not saved.
      Type Parameters:
      T - the type of the publisher
      Parameters:
      type - the publisher to configure
      configuration - the additional configuration options for this job
      See Also:
    • editPublisher

      public <T extends PostBuildStep> void editPublisher(Class<T> type, Consumer<T> configuration)
      Edits this job using the specified configuration lambda. Opens the job configuration view, selects the specified publisher page object, runs the specified configuration lambda, and saves the changes. Afterwards, the job configuration page still is visible and not saved.
      Type Parameters:
      T - the type of the publisher
      Parameters:
      type - the publisher to configure
      configuration - the additional configuration options for this job
    • getPublisher

      public <T extends PostBuildStep> T getPublisher(Class<T> type)
      Getter for a specific publisher previously added to the job. If a publisher of a class is requested which has not been added previously this will result in a NoSuchElementException.
    • addShellStep

      public ShellBuildStep addShellStep(Resource res)
    • addShellStep

      public ShellBuildStep addShellStep(String shell)
    • addBatchStep

      public BatchCommandBuildStep addBatchStep(String batch)
    • addBuildWrapper

      public <T extends BuildWrapper> T addBuildWrapper(Class<T> type)
    • addTrigger

      public <T extends Trigger> T addTrigger(Class<T> type)
    • copyResource

      public void copyResource(Resource resource, String fileName)
      Adds a shell step that copies a resource inside the test project into a file on the build machine.

      Because there's no direct file system access to Jenkins master, we do this by packing file content in base64 and put it as a heredoc in the shell script.

    • copyResourceShell

      protected String copyResourceShell(Resource resource, String fileName)
    • copyResourceBatch

      protected String copyResourceBatch(Resource resource)
    • copyResource

      public void copyResource(Resource resource)
    • copyFile

      public void copyFile(File file)
      "Copy" any file from the System into the Workspace using a zipFIle.

      Differentiates when the file is being run on Windows or Unix based machines.

    • copyDir

      public void copyDir(Resource dir)
    • copyResource

      public void copyResource(String resourcePath)
      "Copies" a resource (can be a single file or a directory) to the jobs workspace by utilizing a shell step.
      Parameters:
      resourcePath - the resource to copy
    • getBuildUrl

      public URL getBuildUrl()
    • startBuild

      public Build startBuild()
    • startBuild

      public Build startBuild(Map<String,?> params)
    • scheduleBuild

      public Build scheduleBuild()
    • scheduleBuild

      public Build scheduleBuild(Map<String,?> params)
    • build

      public Build build(int buildNumber)
    • getLastBuild

      public Build getLastBuild()
    • addParameter

      public <T extends Parameter> T addParameter(Class<T> type)
    • disable

      public void disable()
    • getNextBuildNumber

      public int getNextBuildNumber()
    • getWorkspace

      public Workspace getWorkspace()
    • useCustomWorkspace

      public void useCustomWorkspace(String ws)
    • setLabelExpression

      public void setLabelExpression(String label)
    • shouldBeTiedToLabel

      public Job shouldBeTiedToLabel(String label)
    • shouldHaveBuiltOnOneOfNNodes

      public void shouldHaveBuiltOnOneOfNNodes(List<Node> nodes)
      Verify that the job contains some builds on exact one of the given list of nodes. To test whether the the job has built on the master, the jenkins instance has to be passed in the parameter.
    • pollScm

      public ScmPolling pollScm()
    • delete

      public void delete()
      Deletes the current job.
      Specified by:
      delete in class TopLevelItem
    • disabled

      public static org.hamcrest.Matcher<org.openqa.selenium.WebDriver> disabled()