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 type
R - 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, Loadable, 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.
  • Constructor Details

    • MultiBranchProject

      protected MultiBranchProject(ItemGroup parent, String name)
      Constructor, mandated by TopLevelItem.
      Parameters:
      parent - the parent of this multibranch job.
      name - the name of the multibranch job.
  • Method Details

    • onLoad

      public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
      Specified by:
      onLoad in interface Item
      Overrides:
      onLoad in class com.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 class com.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
    • newDefaultFolderIcon

      protected com.cloudbees.hudson.plugins.folder.FolderIcon newDefaultFolderIcon()
      Overrides:
      newDefaultFolderIcon in class com.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
    • getIconClassName

      public String getIconClassName()
      Specified by:
      getIconClassName in interface IconSpec
    • getSourcePronoun

      public String getSourcePronoun()
      Get the term used in the UI to represent the source for this kind of Item. Must start with a capital letter.
      Returns:
      term used in the UI to represent the source
    • getProjectFactory

      @NonNull public BranchProjectFactory<P,R> getProjectFactory()
      Returns the BranchProjectFactory. ˜
      Returns:
      the BranchProjectFactory.
    • getProjectClass

      public final Class<P> getProjectClass()
      Returns the base class of the projects that are managed by this MultiBranchProject.
      Returns:
      the base class of the projects that are managed by this MultiBranchProject.
      Since:
      2.0
    • setProjectFactory

      public void setProjectFactory(BranchProjectFactory<P,R> projectFactory)
      Parameters:
      projectFactory - the new BranchProjectFactory.
    • 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 interface jenkins.scm.api.SCMSourceOwner
    • getSCMSource

      @CheckForNull public jenkins.scm.api.SCMSource getSCMSource(@CheckForNull String sourceId)
      Specified by:
      getSCMSource in interface jenkins.scm.api.SCMSourceOwner
    • getBranchPropertyStrategy

      @CheckForNull public BranchPropertyStrategy getBranchPropertyStrategy(@NonNull jenkins.scm.api.SCMSource source)
      Returns the BranchPropertyStrategy for a specific SCMSource.
      Parameters:
      source - the specific SCMSource.
      Returns:
      the BranchPropertyStrategy to use.
    • getSCMSourceCriteria

      @CheckForNull public jenkins.scm.api.SCMSourceCriteria getSCMSourceCriteria(@NonNull jenkins.scm.api.SCMSource source)
      Specified by:
      getSCMSourceCriteria in interface jenkins.scm.api.SCMSourceOwner
    • onSCMSourceUpdated

      public void onSCMSourceUpdated(@NonNull jenkins.scm.api.SCMSource source)
      Specified by:
      onSCMSourceUpdated in interface jenkins.scm.api.SCMSourceOwner
    • isHasEvents

      public boolean isHasEvents()
      Overrides:
      isHasEvents in class com.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 class com.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 class com.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 or null if no such job exists.
      Specified by:
      getItem in interface ItemGroup<P extends Job<P,R> & TopLevelItem>
      Overrides:
      getItem in class com.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 or null 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.
      use getItem(String) or AbstractFolder.getJob(String) directly
      Returns the named branch job or null 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 interface AccessControlled
      Overrides:
      getACL in class AbstractItem
    • getDescription

      public String getDescription()
      Overrides:
      getDescription in class AbstractItem
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Item
      Specified by:
      getDisplayName in interface ModelObject
      Specified by:
      getDisplayName in interface ResourceActivity
      Overrides:
      getDisplayName in class AbstractItem
    • getJobsDir

      @NonNull public File getJobsDir()
      Returns the directory that all branches are stored in.
      Overrides:
      getJobsDir in class com.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 interface ItemGroup<P extends Job<P,R> & TopLevelItem>
      Overrides:
      getRootDirFor in class com.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 class com.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 interface Describable<P extends Job<P,R> & TopLevelItem>
      Specified by:
      getDescriptor in interface TopLevelItem
      Overrides:
      getDescriptor in class com.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 class com.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 the SCMSource.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.
    • getView

      public View getView(String name)
      Specified by:
      getView in interface ViewGroup
      Overrides:
      getView in class com.cloudbees.hudson.plugins.folder.AbstractFolder<P extends Job<P,R> & TopLevelItem>
    • isBuildable

      public boolean isBuildable()
      Overrides:
      isBuildable in class com.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 class com.cloudbees.hudson.plugins.folder.computed.ComputedFolder<P extends Job<P,R> & TopLevelItem>
    • rawDecode

      @NonNull public static String rawDecode(@NonNull String s)
      Inverse function of Util.rawEncode(String)
      Parameters:
      s - the encoded string.
      Returns:
      the decoded string.