Package org.jenkinsci.test.acceptance.po
Class Job
-
- 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 otherTopLevelItem
s, useDescribable
annotation to register an implementation.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
CapybaraPortingLayerImpl.Finder<R>, CapybaraPortingLayerImpl.Resolver
-
-
Field Summary
Fields Modifier and Type Field Description Control
concurrentBuild
JenkinsController
controller
The controller that starts/stops Jenkinsprotected List<PostBuildStep>
publishers
-
Fields inherited from class org.jenkinsci.test.acceptance.po.TopLevelItem
name
-
Fields inherited from class org.jenkinsci.test.acceptance.po.PageObject
jsonParser, url
-
Fields inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
driver, injector, LABEL_TO_INPUT_XPATH, time
-
Fields inherited from interface org.jenkinsci.test.acceptance.po.CapybaraPortingLayer
by
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchCommandBuildStep
addBatchStep(String batch)
<T extends BuildStep>
TaddBuildStep(Class<T> type)
<T extends BuildWrapper>
TaddBuildWrapper(Class<T> type)
<T extends Parameter>
TaddParameter(Class<T> type)
<T extends BuildStep>
TaddPreBuildStep(Class<T> type)
<T extends PostBuildStep>
TaddPublisher(Class<T> publisherClass)
Adds the specified publisher to this job.<T extends PostBuildStep>
TaddPublisher(Class<T> type, Consumer<T> configuration)
Adds the specified publisher to this job.ShellBuildStep
addShellStep(String shell)
ShellBuildStep
addShellStep(Resource res)
<T extends Trigger>
TaddTrigger(Class<T> type)
Build
build(int buildNumber)
void
copyDir(Resource dir)
void
copyFile(File file)
"Copy" any file from the System into the Workspace using a zipFIle.void
copyResource(String resourcePath)
"Copies" a resource (can be a single file or a directory) to the jobs workspace by utilizing a shell step.void
copyResource(Resource resource)
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.protected String
copyResourceBatch(Resource resource)
protected String
copyResourceShell(Resource resource, String fileName)
void
delete()
Deletes the current job.void
disable()
static org.hamcrest.Matcher<org.openqa.selenium.WebDriver>
disabled()
<T extends PostBuildStep>
voideditPublisher(Class<T> type, Consumer<T> configuration)
Edits this job using the specified configuration lambda.URL
getBuildUrl()
Build
getLastBuild()
int
getNextBuildNumber()
List<Parameter>
getParameters()
<T extends PostBuildStep>
TgetPublisher(Class<T> type)
Getter for a specific publisher previously added to the job.Workspace
getWorkspace()
ScmPolling
pollScm()
void
removeFirstBuildStep()
Build
scheduleBuild()
Build
scheduleBuild(Map<String,?> params)
void
setLabelExpression(String label)
Job
shouldBeTiedToLabel(String label)
void
shouldHaveBuiltOnOneOfNNodes(List<Node> nodes)
Verify that the job contains some builds on exact one of the given list of nodes.Build
startBuild()
Build
startBuild(Map<String,?> params)
void
useCustomWorkspace(String ws)
<T extends Scm>
TuseScm(Class<T> type)
-
Methods inherited from class org.jenkinsci.test.acceptance.po.TopLevelItem
as, description, equals, getDescription, getDisplayName, hashCode, renameTo, setDescription, setDescription, toString
-
Methods inherited from class org.jenkinsci.test.acceptance.po.ContainerPageObject
action, action, getConfigUrl, getJson, getJson, getJsonApiUrl, getNavigationLinks
-
Methods inherited from class org.jenkinsci.test.acceptance.po.ConfigurablePageObject
apply, configure, configure, configure, configure, ensureConfigPage, getFormName, getSubmitButtonText, save
-
Methods inherited from class org.jenkinsci.test.acceptance.po.PageObject
control, control, createPageArea, createRandomName, getContext, getJenkins, open, url, url, visit
-
Methods inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
all, blur, check, check, check, choose, clickButton, clickLink, confirmAlert, elasticSleep, executeScript, fillIn, find, findCaption, findCaption, findIfNotVisible, getCurrentUrl, getCurrentUrlWithFragment, getElement, getPageContent, getPageSource, getPageSource, getPath, handleAlert, isStale, last, lastIfNotVisible, newInstance, resource, runThenConfirmAlert, runThenConfirmAlert, runThenHandleAlert, runThenHandleAlert, sleep, visit, waitFor, waitFor, waitFor, waitFor, waitFor, waitForCond, waitForCond
-
-
-
-
Field Detail
-
controller
@Inject public JenkinsController controller
The controller that starts/stops Jenkins
-
publishers
protected List<PostBuildStep> publishers
-
concurrentBuild
public final Control concurrentBuild
-
-
Constructor Detail
-
Job
public Job(PageObject context, URL url, String name)
-
-
Method Detail
-
getParameters
public List<Parameter> getParameters()
- Overrides:
getParameters
in classTopLevelItem
-
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:
getPublisher(Class)
,editPublisher(Class, Consumer)
-
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 configureconfiguration
- the additional configuration options for this job- See Also:
getPublisher(Class)
,editPublisher(Class, Consumer)
-
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 configureconfiguration
- 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 aNoSuchElementException
.
-
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)
-
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.
-
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()
-
scheduleBuild
public Build scheduleBuild()
-
build
public Build build(int buildNumber)
-
getLastBuild
public Build getLastBuild()
-
disable
public void disable()
-
getNextBuildNumber
public int getNextBuildNumber()
-
getWorkspace
public Workspace getWorkspace()
-
useCustomWorkspace
public void useCustomWorkspace(String ws)
-
setLabelExpression
public void setLabelExpression(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 classTopLevelItem
-
disabled
public static org.hamcrest.Matcher<org.openqa.selenium.WebDriver> disabled()
-
-