Package jenkins.branch
Class MultiBranchProject<P extends Job<P,R> & TopLevelItem,R extends Run<P,R>>
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Actionable
-
- hudson.model.AbstractItem
-
- com.cloudbees.hudson.plugins.folder.AbstractFolder<I>
-
- com.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P>
-
- jenkins.branch.MultiBranchProject<P,R>
-
- Type Parameters:
P
- the project typeR
- the run type
- All Implemented Interfaces:
ExtensionPoint
,BuildableItem
,Describable<TopLevelItem>
,DescriptorByNameOwner
,Item
,ItemGroup<P>
,ModelObject
,ModifiableViewGroup
,PersistenceRoot
,Queue.FlyweightTask
,SubTask
,Queue.Task
,ResourceActivity
,Saveable
,TopLevelItem
,ViewGroup
,SearchableModelObject
,SearchItem
,AccessControlled
,ModelObjectWithChildren
,ModelObjectWithContextMenu
,jenkins.scm.api.SCMSourceOwner
,TriggeredItem
,OnMaster
,IconSpec
,org.kohsuke.stapler.HttpDeletable
,org.kohsuke.stapler.StaplerFallback
,org.kohsuke.stapler.StaplerOverridable
,org.kohsuke.stapler.StaplerProxy
public abstract class MultiBranchProject<P extends Job<P,R> & TopLevelItem,R extends Run<P,R>> extends com.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P> implements jenkins.scm.api.SCMSourceOwner, IconSpec
Abstract base class for multiple-branch based projects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MultiBranchProject.BranchIndexing<P extends Job<P,R> & TopLevelItem,R extends Run<P,R>>
Represents the branch indexing job.static class
MultiBranchProject.CopyItemVeto
Veto attempts to copy branch projects outside of their multibranch container.static class
MultiBranchProject.SCMEventListenerImpl
Our event listener.static class
MultiBranchProject.StateActionFactory
Adds theMultiBranchProject.State.sourceActions
toActionable.getAllActions()
.-
Nested classes/interfaces inherited from class com.cloudbees.hudson.plugins.folder.AbstractFolder
com.cloudbees.hudson.plugins.folder.AbstractFolder.ItemListenerImpl, com.cloudbees.hudson.plugins.folder.AbstractFolder.RunListenerImpl
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
-
Field Summary
-
Fields inherited from class hudson.model.AbstractItem
description, displayName, name, PRONOUN, SKIP_PERMISSION_CHECK, TASK_NOUN
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MultiBranchProject(ItemGroup parent, String name)
Constructor, mandated byTopLevelItem
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
computeChildren(com.cloudbees.hudson.plugins.folder.computed.ChildObserver<P> observer, TaskListener listener)
protected com.cloudbees.hudson.plugins.folder.computed.FolderComputation<P>
createComputation(com.cloudbees.hudson.plugins.folder.computed.FolderComputation<P> previous)
protected void
fireSCMSourceAfterSave(List<jenkins.scm.api.SCMSource> sources)
Fires theSCMSource.afterSave()
method for the supplied sources.ACL
getACL()
P
getBranch(String name)
Deprecated.usegetItem(String)
orAbstractFolder.getJob(String)
directlyBranchPropertyStrategy
getBranchPropertyStrategy(jenkins.scm.api.SCMSource source)
Returns theBranchPropertyStrategy
for a specificSCMSource
.File
getComputationDir()
Returns the directory that branch indexing is stored in.String
getDescription()
MultiBranchProjectDescriptor
getDescriptor()
String
getDisplayName()
String
getIconClassName()
MultiBranchProject.BranchIndexing<P,R>
getIndexing()
Returns the current/most recent indexing details.P
getItem(String name)
Returns the named child job ornull
if no such job exists.P
getItemByBranchName(String branchName)
Returns the child job with the specified branch name ornull
if no such child job exists.File
getJobsDir()
Returns the directory that all branches are stored in.Class<P>
getProjectClass()
Returns the base class of the projects that are managed by thisMultiBranchProject
.BranchProjectFactory<P,R>
getProjectFactory()
Returns theBranchProjectFactory
.File
getRootDirFor(P child)
jenkins.scm.api.SCMSource
getSCMSource(String sourceId)
jenkins.scm.api.SCMSourceCriteria
getSCMSourceCriteria(jenkins.scm.api.SCMSource source)
List<jenkins.scm.api.SCMSource>
getSCMSources()
String
getSourcePronoun()
Get the term used in the UI to represent the source for this kind ofItem
.List<BranchSource>
getSources()
The sources of branches.PersistedList<BranchSource>
getSourcesList()
Offers direct access to the configurable list of branch sources.View
getView(String name)
protected View
getWelcomeView()
Creates a place-holder view when there's no active branch indexed.boolean
isBuildable()
boolean
isHasEvents()
protected com.cloudbees.hudson.plugins.folder.FolderIcon
newDefaultFolderIcon()
protected com.cloudbees.hudson.plugins.folder.views.AbstractFolderViewHolder
newFolderViewHolder()
protected abstract BranchProjectFactory<P,R>
newProjectFactory()
Creates a new instance of the default project factory to be used for a new instance of the project type.void
onLoad(ItemGroup<? extends Item> parent, String name)
void
onSCMSourceUpdated(jenkins.scm.api.SCMSource source)
protected Collection<P>
orphanedItems(Collection<P> orphaned, TaskListener listener)
static String
rawDecode(String s)
Inverse function ofUtil.rawEncode(String)
void
setProjectFactory(BranchProjectFactory<P,R> projectFactory)
Sets theBranchProjectFactory
.void
setSourcesList(List<BranchSource> sources)
Offers direct access to set the configurable list of branch sources while preserving branch source id associations for sources that are otherwise unmodifiedprotected void
submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
-
Methods inherited from class com.cloudbees.hudson.plugins.folder.computed.ComputedFolder
addTrigger, checkAbortPermission, checkRename, createEventsChildObserver, createExecutable, doBuild, doConfigSubmit, getActions, getAssignedLabel, getCauseOfBlockage, getComputation, getEstimatedDuration, getLastBuiltOn, getLastFailedBuild, getLastStableBuild, getLastSuccessfulBuild, getOrphanedItemStrategy, getOrphanedItemStrategyDescriptors, getSuccessfulDestination, getTriggerDescriptors, getTriggers, hasAbortPermission, init, isDisabled, onCreatedFromScratch, openEventsChildObserver, recalculateAfterSubmitted, removeTrigger, scheduleBuild, scheduleBuild, scheduleBuild2, setDisabled, setOrphanedItemStrategy, supportsMakeDisabled
-
Methods inherited from class com.cloudbees.hudson.plugins.folder.AbstractFolder
addProperty, addView, canDelete, delete, deleteView, doChildrenContextMenu, doCreateView, doDisable, doEnable, doLastBuild, doSubmitDescription, doViewExistsCheck, getAllJobs, getBuildHealth, getBuildHealthReports, getFolderViews, getHealthMetrics, getIcon, getIconColor, getItemGroup, getItems, getItems, getJob, getOverrides, getPrimaryView, getPronoun, getProperties, getRootDirFor, getStaplerFallback, getUrlChildPrefix, getViewActions, getViews, getViewsTabBar, hasVisibleItems, initViews, invalidateBuildHealthReports, isNameEditable, itemsPut, loadChildren, loadJobTotal, makeDisabled, makeSearchIndex, newDefaultViewsTabBar, onDeleted, onRenamed, onViewRenamed, renameBlocker, renameTo, resetFolderViews, save, setIcon, setPrimaryView
-
Methods inherited from class hudson.model.AbstractItem
delete, doCheckNewName, doConfigDotXml, doConfirmRename, doDoDelete, doReload, doSetName, getAbsoluteUrl, getApi, getConfigFile, getDisplayNameOrNull, getFullDisplayName, getFullName, getName, getParent, getRelativeDisplayNameFrom, getRelativeNameFromGroup, getRootDir, getSearchName, getSearchUrl, getShortUrl, getTarget, getTaskNoun, getUrl, movedTo, onCopiedFrom, performDelete, resolveForCLI, setDescription, setDisplayName, setDisplayNameOrNull, toString, updateByXml, updateByXml, writeConfigDotXml, writeReplace
-
Methods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, getAction, getAction, getActions, getAllActions, getDynamic, removeAction, removeActions, replaceAction, replaceActions
-
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
-
Methods inherited from interface hudson.model.BuildableItem
scheduleBuild, scheduleBuild
-
Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByName
-
Methods inherited from interface hudson.model.Item
delete, getAbsoluteUrl, getAllJobs, getFullDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getShortUrl, getUrl, onCopiedFrom, onCreatedFromScratch, save
-
Methods inherited from interface hudson.model.ItemGroup
allItems, allItems, allItems, getAllItems, getAllItems, getAllItems, getFullDisplayName, getFullName, getItemsStream, getItemsStream, getUrl
-
Methods inherited from interface hudson.model.PersistenceRoot
getRootDir
-
Methods inherited from interface hudson.model.Queue.Task
getAffinityKey, getDefaultAuthentication, getDefaultAuthentication, getDefaultAuthentication2, getDefaultAuthentication2, getFullDisplayName, getName, getSubTasks, getUrl, getWhyBlocked, isBuildBlocked, isConcurrentBuild
-
Methods inherited from interface hudson.model.ResourceActivity
getResourceList
-
Methods inherited from interface hudson.search.SearchableModelObject
getSearch
-
Methods inherited from interface hudson.search.SearchItem
getSearchIndex, getSearchName, getSearchUrl
-
Methods inherited from interface hudson.model.queue.SubTask
getOwnerExecutable, getOwnerTask, getSameNodeConstraint
-
Methods inherited from interface hudson.model.ViewGroup
getAllViews, getUrl
-
-
-
-
Constructor Detail
-
MultiBranchProject
protected MultiBranchProject(ItemGroup parent, String name)
Constructor, mandated byTopLevelItem
.- Parameters:
parent
- the parent of this multibranch job.name
- the name of the multibranch job.
-
-
Method Detail
-
onLoad
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
- Specified by:
onLoad
in interfaceItem
- Overrides:
onLoad
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
- Throws:
IOException
-
newFolderViewHolder
protected com.cloudbees.hudson.plugins.folder.views.AbstractFolderViewHolder newFolderViewHolder()
- Overrides:
newFolderViewHolder
in classcom.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
-
newDefaultFolderIcon
protected com.cloudbees.hudson.plugins.folder.FolderIcon newDefaultFolderIcon()
- Overrides:
newDefaultFolderIcon
in classcom.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
-
getIconClassName
public String getIconClassName()
- Specified by:
getIconClassName
in interfaceIconSpec
-
getSourcePronoun
public String getSourcePronoun()
Get the term used in the UI to represent the source for this kind ofItem
. Must start with a capital letter.- Returns:
- term used in the UI to represent the source
-
getProjectFactory
@NonNull public BranchProjectFactory<P,R> getProjectFactory()
Returns theBranchProjectFactory
. ˜- Returns:
- the
BranchProjectFactory
.
-
getProjectClass
public final Class<P> getProjectClass()
Returns the base class of the projects that are managed by thisMultiBranchProject
.- Returns:
- the base class of the projects that are managed by this
MultiBranchProject
. - Since:
- 2.0
-
setProjectFactory
public void setProjectFactory(BranchProjectFactory<P,R> projectFactory)
Sets theBranchProjectFactory
.- Parameters:
projectFactory
- the newBranchProjectFactory
.
-
newProjectFactory
@NonNull protected abstract BranchProjectFactory<P,R> newProjectFactory()
Creates a new instance of the default project factory to be used for a new instance of the project type.- Returns:
- a new default
BranchProjectFactory
.
-
getSources
@Exported @NonNull public List<BranchSource> getSources()
The sources of branches.- Returns:
- the sources of branches.
-
getSourcesList
@NonNull public PersistedList<BranchSource> getSourcesList()
Offers direct access to the configurable list of branch sources. Intended for use from scripting and testing.- Returns:
- the sources list.
-
setSourcesList
public void setSourcesList(List<BranchSource> sources) throws IOException
Offers direct access to set the configurable list of branch sources while preserving branch source id associations for sources that are otherwise unmodified- Parameters:
sources
- the new sources.- Throws:
IOException
- if the sources could not be persisted to disk.
-
getSCMSources
@NonNull public List<jenkins.scm.api.SCMSource> getSCMSources()
- Specified by:
getSCMSources
in interfacejenkins.scm.api.SCMSourceOwner
-
getSCMSource
@CheckForNull public jenkins.scm.api.SCMSource getSCMSource(@CheckForNull String sourceId)
- Specified by:
getSCMSource
in interfacejenkins.scm.api.SCMSourceOwner
-
getBranchPropertyStrategy
@CheckForNull public BranchPropertyStrategy getBranchPropertyStrategy(@NonNull jenkins.scm.api.SCMSource source)
Returns theBranchPropertyStrategy
for a specificSCMSource
.- Parameters:
source
- the specificSCMSource
.- Returns:
- the
BranchPropertyStrategy
to use.
-
getSCMSourceCriteria
@CheckForNull public jenkins.scm.api.SCMSourceCriteria getSCMSourceCriteria(@NonNull jenkins.scm.api.SCMSource source)
- Specified by:
getSCMSourceCriteria
in interfacejenkins.scm.api.SCMSourceOwner
-
onSCMSourceUpdated
public void onSCMSourceUpdated(@NonNull jenkins.scm.api.SCMSource source)
- Specified by:
onSCMSourceUpdated
in interfacejenkins.scm.api.SCMSourceOwner
-
isHasEvents
public boolean isHasEvents()
- Overrides:
isHasEvents
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
-
computeChildren
protected void computeChildren(com.cloudbees.hudson.plugins.folder.computed.ChildObserver<P> observer, TaskListener listener) throws IOException, InterruptedException
- Specified by:
computeChildren
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
- Throws:
IOException
InterruptedException
-
orphanedItems
protected Collection<P> orphanedItems(Collection<P> orphaned, TaskListener listener) throws IOException, InterruptedException
- Overrides:
orphanedItems
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
- Throws:
IOException
InterruptedException
-
getItem
@CheckForNull public P getItem(String name)
Returns the named child job ornull
if no such job exists.- Specified by:
getItem
in interfaceItemGroup<P extends Job<P,R> & TopLevelItem>
- Overrides:
getItem
in classcom.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
- Parameters:
name
- the name of the child job.- Returns:
- the named child job or
null
if no such job exists.
-
getItemByBranchName
@CheckForNull public P getItemByBranchName(@NonNull String branchName)
Returns the child job with the specified branch name ornull
if no such child job exists.- Parameters:
branchName
- the name of the branch.- Returns:
- the child job or
null
if no such job exists or if the requesting user does ave permission to view it. - Since:
- 2.0.0
-
getBranch
@Deprecated @CheckForNull public P getBranch(String name)
Deprecated.usegetItem(String)
orAbstractFolder.getJob(String)
directlyReturns the named branch job ornull
if no such branch exists.- Parameters:
name
- the name of the branch- Returns:
- the named branch job or
null
if no such branch exists.
-
getACL
@NonNull public ACL getACL()
- Specified by:
getACL
in interfaceAccessControlled
- Overrides:
getACL
in classAbstractItem
-
getDescription
public String getDescription()
- Overrides:
getDescription
in classAbstractItem
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceItem
- Specified by:
getDisplayName
in interfaceModelObject
- Specified by:
getDisplayName
in interfaceResourceActivity
- Overrides:
getDisplayName
in classAbstractItem
-
getJobsDir
@NonNull public File getJobsDir()
Returns the directory that all branches are stored in.- Overrides:
getJobsDir
in classcom.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
- Returns:
- the directory that all branches are stored in.
-
getRootDirFor
public File getRootDirFor(P child)
- Specified by:
getRootDirFor
in interfaceItemGroup<P extends Job<P,R> & TopLevelItem>
- Overrides:
getRootDirFor
in classcom.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
-
getComputationDir
@NonNull public File getComputationDir()
Returns the directory that branch indexing is stored in.- Overrides:
getComputationDir
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
- Returns:
- the directory that branch indexing is stored in.
-
getDescriptor
@NonNull public MultiBranchProjectDescriptor getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<P extends Job<P,R> & TopLevelItem>
- Specified by:
getDescriptor
in interfaceTopLevelItem
- Overrides:
getDescriptor
in classcom.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
-
getIndexing
public MultiBranchProject.BranchIndexing<P,R> getIndexing()
Returns the current/most recent indexing details.- Returns:
- the current/most recent indexing details.
-
submit
protected void submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException
- Overrides:
submit
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
- Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException
-
fireSCMSourceAfterSave
protected void fireSCMSourceAfterSave(List<jenkins.scm.api.SCMSource> sources)
Fires theSCMSource.afterSave()
method for the supplied sources.- Parameters:
sources
- the sources.
-
getWelcomeView
protected View getWelcomeView()
Creates a place-holder view when there's no active branch indexed.- Returns:
- the place-holder view when there's no active branch indexed.
-
isBuildable
public boolean isBuildable()
- Overrides:
isBuildable
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
-
createComputation
@NonNull protected com.cloudbees.hudson.plugins.folder.computed.FolderComputation<P> createComputation(com.cloudbees.hudson.plugins.folder.computed.FolderComputation<P> previous)
- Overrides:
createComputation
in classcom.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
-
rawDecode
@NonNull public static String rawDecode(@NonNull String s)
Inverse function ofUtil.rawEncode(String)
- Parameters:
s
- the encoded string.- Returns:
- the decoded string.
-
-