Package jenkins.branch
Class BranchProjectFactory<P extends Job<P,R> & TopLevelItem,R extends Run<P,R>>
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<BranchProjectFactory<?,?>>
-
- jenkins.branch.BranchProjectFactory<P,R>
-
- Type Parameters:
P
- the type of the branch projects.R
- the type of the builds of the branch projects.
- All Implemented Interfaces:
ExtensionPoint
,Describable<BranchProjectFactory<?,?>>
,Saveable
public abstract class BranchProjectFactory<P extends Job<P,R> & TopLevelItem,R extends Run<P,R>> extends AbstractDescribableImpl<BranchProjectFactory<?,?>> implements Saveable, ExtensionPoint
Creates instances of the branch projects for a specificBranch
and also provides some utility methods for updating the branch specific projects. Please define a 'getting-started' view for a subclass, if you would like to provide specific information to the user how to get started using the type of project factory. This view is displayed when there are no subfolders found.- Author:
- Stephen Connolly
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BranchProjectFactory.HeadByItemImpl
static class
BranchProjectFactory.SourceByItemImpl
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description BranchProjectFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description P
asProject(Item item)
Casts theItem
into the project type supported by thisBranchProjectFactory
.P
decorate(P project)
Decorates the project in with all theJobDecorator
instances.abstract Branch
getBranch(P project)
Gets theBranch
that a specific project was configured for.BranchProjectFactoryDescriptor
getDescriptor()
jenkins.scm.api.SCMRevision
getLastSeenRevision(P project)
Gets theSCMRevision
that the project was last seen for.MultiBranchProject<P,R>
getOwner()
Gets the current owner.Class<P>
getProjectClass()
Returns the base class of the projects that are produced by this factory.jenkins.scm.api.SCMRevision
getRevision(P project)
Gets theSCMRevision
that the project was last built for.abstract boolean
isProject(Item item)
Test if the specifiedItem
is the branch project type supported by thisBranchProjectFactory
abstract P
newInstance(Branch branch)
Creates a new branch project.void
save()
Saves theBranchProjectFactory
abstract P
setBranch(P project, Branch branch)
void
setLastSeenRevisionHash(P project, jenkins.scm.api.SCMRevision revision)
Sets theSCMRevision
that the project was last seenvoid
setOwner(MultiBranchProject<P,R> owner)
Sets the owner.void
setRevisionHash(P project, jenkins.scm.api.SCMRevision revision)
Sets theSCMRevision
that the project was last built for.
-
-
-
Method Detail
-
newInstance
public abstract P newInstance(Branch branch)
Creates a new branch project.Item.getName()
must matchBranch.getEncodedName()
.- Parameters:
branch
- the branch.- Returns:
- the new branch project instance.
-
save
public void save() throws IOException
Saves theBranchProjectFactory
- Specified by:
save
in interfaceSaveable
- Throws:
IOException
- if issues saving.
-
setOwner
public void setOwner(MultiBranchProject<P,R> owner)
Sets the owner.- Parameters:
owner
- the owner.
-
getOwner
public MultiBranchProject<P,R> getOwner()
Gets the current owner.- Returns:
- the current owner.
-
getBranch
@NonNull public abstract Branch getBranch(@NonNull P project)
Gets theBranch
that a specific project was configured for.- Parameters:
project
- the project; should assumeisProject(hudson.model.Item)
has already been tested on it- Returns:
- the
Branch
that the project was configured for.
-
setBranch
@NonNull public abstract P setBranch(@NonNull P project, @NonNull Branch branch)
- Parameters:
project
- the project.branch
- the new branch.- Returns:
- the project.
-
isProject
public abstract boolean isProject(@CheckForNull Item item)
Test if the specifiedItem
is the branch project type supported by thisBranchProjectFactory
- Parameters:
item
- theItem
- Returns:
true
if and only if theItem
is a project supported by thisBranchProjectFactory
.
-
asProject
@NonNull public P asProject(@NonNull Item item)
Casts theItem
into the project type supported by thisBranchProjectFactory
.- Parameters:
item
- theItem
.- Returns:
- the
Item
upcast to the project type supported by thisBranchProjectFactory
.
-
getRevision
@CheckForNull public jenkins.scm.api.SCMRevision getRevision(P project)
Gets theSCMRevision
that the project was last built for.- Parameters:
project
- the project.- Returns:
- the
SCMRevision
of the last build.
-
setRevisionHash
public void setRevisionHash(P project, jenkins.scm.api.SCMRevision revision) throws IOException
Sets theSCMRevision
that the project was last built for.- Parameters:
project
- the project.revision
- theSCMRevision
of the last build.- Throws:
IOException
- if there was an issue persisting the details.
-
getLastSeenRevision
@CheckForNull public jenkins.scm.api.SCMRevision getLastSeenRevision(P project)
Gets theSCMRevision
that the project was last seen for.- Parameters:
project
- the project.- Returns:
- the
SCMRevision
of the last seen.
-
setLastSeenRevisionHash
public void setLastSeenRevisionHash(P project, jenkins.scm.api.SCMRevision revision) throws IOException
Sets theSCMRevision
that the project was last seen- Parameters:
project
- the project.revision
- theSCMRevision
of the last build.- Throws:
IOException
- if there was an issue persisting the details.
-
decorate
public P decorate(P project)
Decorates the project in with all theJobDecorator
instances. NOTE: This method should suppress saving the project and only affect the in-memory state. NOTE: Override if the default strategy is not appropriate for the specific project type.- Parameters:
project
- the project.- Returns:
- the project for nicer method chaining
-
getDescriptor
@NonNull public BranchProjectFactoryDescriptor getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<P extends Job<P,R> & TopLevelItem>
- Overrides:
getDescriptor
in classAbstractDescribableImpl<BranchProjectFactory<?,?>>
-
-