hudson.model
Class AbstractProject<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.Actionable
          extended by hudson.model.AbstractItem
              extended by hudson.model.Job<P,R>
                  extended by hudson.model.AbstractProject<P,R>
All Implemented Interfaces:
ExtensionPoint, BuildableItem, DescriptorByNameOwner, Item, ModelObject, PersistenceRoot, SubTask, Queue.Task, ResourceActivity, Saveable, SearchableModelObject, SearchItem, AccessControlled, ModelObjectWithContextMenu, OnMaster, org.kohsuke.stapler.HttpDeletable, org.kohsuke.stapler.StaplerOverridable
Direct Known Subclasses:
AbstractMavenProject, MatrixProject, Project

public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
extends Job<P,R>
implements BuildableItem

Base implementation of Jobs that build software. For now this is primarily the common part of Project and MavenModule.

Author:
Kohsuke Kawaguchi
See Also:
AbstractBuild

Nested Class Summary
static class AbstractProject.AbstractProjectDescriptor
          AbstractProject subtypes should implement this base class as a descriptor.
static class AbstractProject.BecauseOfBuildInProgress
          Blocked because the previous build is already in progress.
static class AbstractProject.BecauseOfDownstreamBuildInProgress
          Because the downstream build is in progress, and we are configured to wait for that.
static class AbstractProject.BecauseOfUpstreamBuildInProgress
          Because the upstream build is in progress, and we are configured to wait for that.
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.MenuItem
 
Field Summary
static Permission ABORT
          Permission to abort a build
protected  boolean blockBuildWhenDownstreamBuilding
          True to keep builds of this project in queue when downstream projects are building.
protected  boolean blockBuildWhenUpstreamBuilding
          True to keep builds of this project in queue when upstream projects are building.
static AlternativeUiTextProvider.Message<AbstractProject> BUILD_NOW_TEXT
          Replaceable "Build Now" text.
protected  RunMap<R> builds
          All the builds keyed by their build number.
protected  boolean disabled
          True to suspend new builds.
protected  List<Action> transientActions
          Actions contributed from subsidiary objects associated with AbstractProject, such as from triggers, builders, publishers, etc.
protected  List<Trigger<?>> triggers
          List of all Triggers for this project.
 
Fields inherited from class hudson.model.Job
HISTORY_ADAPTER, nextBuildNumber, properties
 
Fields inherited from class hudson.model.AbstractItem
description, displayName, name, PRONOUN
 
Fields inherited from interface hudson.model.Item
BUILD, CANCEL, CONFIGURE, CREATE, DELETE, DISCOVER, EXTENDED_READ, PERMISSIONS, READ, WIPEOUT, WORKSPACE
 
Fields inherited from interface hudson.model.Saveable
NOOP
 
Constructor Summary
protected AbstractProject(ItemGroup parent, String name)
           
 
Method Summary
 RunMap<R> _getRuns()
          Gets all the runs.
 void addProperty(JobProperty<? super P> jobProp)
          Adds JobProperty.
protected
<T extends Describable<T>>
void
addToList(T item, List<T> collection)
           
 void addTrigger(Trigger<?> trigger)
          Adds a new Trigger to this Project if not active yet.
 boolean blockBuildWhenDownstreamBuilding()
           
 boolean blockBuildWhenUpstreamBuilding()
           
protected abstract  void buildDependencyGraph(DependencyGraph graph)
          Builds the dependency graph.
protected
<T extends Describable<T>>
List<T>
buildDescribable(org.kohsuke.stapler.StaplerRequest req, List<? extends Descriptor<T>> descriptors)
           
protected
<T extends Describable<T>>
List<T>
buildDescribable(org.kohsuke.stapler.StaplerRequest req, List<? extends Descriptor<T>> descriptors, String prefix)
          Deprecated. As of 1.261. Use buildDescribable(StaplerRequest, List) instead.
 void checkAbortPermission()
          Checks the permission to see if the current user can abort this executable.
 boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile)
           
 R createExecutable()
          Creates Queue.Executable, which performs the actual execution of the task.
protected  HistoryWidget createHistoryWidget()
           
protected  List<Action> createTransientActions()
           
 void disable()
           
 void doBuild(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, TimeDuration delay)
          Schedules a new build command.
 void doBuildWithParameters(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, TimeDuration delay)
          Supports build trigger with parameters via an HTTP GET or POST.
 void doCancelQueue(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Cancels a scheduled build.
 FormValidation doCheckRetryCount(String value)
          Validates the retry count Regex
 void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Accepts submission from the configuration page.
 org.kohsuke.stapler.HttpResponse doDisable()
           
 void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Deletes this project.
 org.kohsuke.stapler.HttpResponse doDoWipeOutWorkspace()
          Wipes out the workspace.
 org.kohsuke.stapler.HttpResponse doEnable()
           
 void doPolling(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Schedules a new SCM polling command.
 void doRssChangelog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          RSS feed for changes in this project.
 DirectoryBrowserSupport doWs(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Serves the workspace files.
 void enable()
           
static AbstractProject findNearest(String name)
          Finds a AbstractProject that has the name closest to the given name.
static AbstractProject findNearest(String name, ItemGroup context)
          Finds a AbstractProject whose name (when referenced from the specified context) is closest to the given name.
 List<Action> getActions()
          Gets actions contributed to this build.
 Label getAssignedLabel()
          If this project is configured to be always built on this node, return that Node.
 String getAssignedLabelString()
          Gets the textual representation of the assigned label as it was entered by the user.
 BuildAuthorizationToken getAuthToken()
           
 R getBuild(String id)
           More efficient implementation.
 R getBuildByNumber(int n)
           More efficient implementation.
protected abstract  Class<R> getBuildClass()
          Determines Class<R>.
 AbstractProject getBuildingDownstream()
          Returns the project if any of the downstream project is either building, waiting, pending or buildable.
 AbstractProject getBuildingUpstream()
          Returns the project if any of the upstream project is either building or is in the queue.
 String getBuildNowText()
          Gets the human readable display name to be rendered in the "Build Now" link.
 List<AbstractProject> getBuildTriggerUpstreamProjects()
          Returns only those upstream projects that defines BuildTrigger to this project.
 CauseOfBlockage getCauseOfBlockage()
          If the execution of this task should be blocked for temporary reasons, this method returns a non-null object explaining why.
 String getCustomWorkspace()
           
 int getDelay(org.kohsuke.stapler.StaplerRequest req)
          Deprecated. as of 1.488 Inject TimeDuration.
 List<AbstractProject> getDownstreamProjects()
          Gets the other AbstractProjects that should be built when a build of this project is completed.
 EnvVars getEnvironment(Node node, TaskListener listener)
          Creates an environment variable override for launching processes for this project.
 R getFirstBuild()
          Returns the oldest build in the record.
 boolean getHasCustomQuietPeriod()
           
 BallColor getIconColor()
          Used as the color of the status ball for the project.
 JDK getJDK()
          Gets the JDK that this project is configured with, or null.
 R getLastBuild()
          Returns the last build.
 Node getLastBuiltOn()
          Gets the Node where this project was last built on.
 FilePath getModuleRoot()
          Deprecated. as of 1.319 See getWorkspace() for a migration strategy.
 FilePath[] getModuleRoots()
          Deprecated. as of 1.319 See getWorkspace() for a migration strategy.
 R getNearestBuild(int n)
          Gets the youngest build #m that satisfies n<=m.
 R getNearestOldBuild(int n)
          Gets the latest build #m that satisfies m<=n.
 Queue.Task getOwnerTask()
          Gets the Queue.Task that this subtask belongs to.
 List<ProminentProjectAction> getProminentActions()
           
 String getPronoun()
          Get the term used in the UI to represent this kind of AbstractProject.
abstract  DescribableList<Publisher,Descriptor<Publisher>> getPublishersList()
          Returns the live list of all Publishers configured for this project.
 Queue.Item getQueueItem()
          If this job is in the build queue, return its item.
 int getQuietPeriod()
           
 SortedMap<Integer,Fingerprint.RangeSet> getRelationship(AbstractProject that)
          Gets the dependency relationship map between this project (as the source) and that project (as the sink.)
 Set<Label> getRelevantLabels()
          Set of labels relevant to this job.
protected  Set<ResourceActivity> getResourceActivities()
          Set of child resource activities of the build of this project (override in child projects).
 ResourceList getResourceList()
          List of necessary resources to perform the build of this project.
 AbstractProject<?,?> getRootProject()
          Gets the nearest ancestor TopLevelItem that's also an AbstractProject.
 Object getSameNodeConstraint()
          If a subset of SubTasks of a Queue.Task needs to be collocated with other SubTasks, those SubTasks should return the equal object here.
 SCM getScm()
           
 int getScmCheckoutRetryCount()
           
 SCMCheckoutStrategy getScmCheckoutStrategy()
           
 R getSomeBuildWithWorkspace()
          Gets some build that has a live workspace.
 FilePath getSomeWorkspace()
          Gets a workspace for some build of this project.
 List<SubTask> getSubTasks()
          Obtains the SubTasks that constitute this task.
 Set<AbstractProject> getTransitiveDownstreamProjects()
          Gets all the downstream projects including transitive downstream projects.
 Set<AbstractProject> getTransitiveUpstreamProjects()
          Gets all the upstream projects including transitive upstream projects.
<T extends Trigger>
T
getTrigger(Class<T> clazz)
          Gets the specific trigger, or null if the propert is not configured for this job.
 Map<TriggerDescriptor,Trigger> getTriggers()
           
 List<AbstractProject> getUpstreamProjects()
           
 String getWhyBlocked()
           
 FilePath getWorkspace()
          Deprecated. as of 1.319 To support concurrent builds of the same project, this method is moved to AbstractBuild. For backward compatibility, this method returns the right AbstractBuild.getWorkspace() if called from Executor, and otherwise the workspace of the last build.

If you are calling this method during a build from an executor, switch it to AbstractBuild.getWorkspace(). If you are calling this method to serve a file from the workspace, doing a form validation, etc., then use getSomeWorkspace()

 Resource getWorkspaceResource()
          Deprecated. as of 1.319 Projects no longer have a fixed workspace, ands builds will find an available workspace via WorkspaceList for each build (furthermore, that happens after a build is started.) So a Resource representation for a workspace at the project level no longer makes sense.

If you need to lock a workspace while you do some computation, see the source code of pollSCMChanges(TaskListener) for how to obtain a lock of a workspace through WorkspaceList.

 boolean hasAbortPermission()
          Works just like Queue.Task.checkAbortPermission() except it indicates the status by a return value, instead of exception.
 boolean hasCustomScmCheckoutRetryCount()
           
 boolean hasParticipant(User user)
          Returns true if this user has made a commit to this project.
 boolean isBuildable()
          Returns true if we should display "build now" icon
 boolean isBuildBlocked()
          Returns true if the execution should be blocked for temporary reasons.
 boolean isConcurrentBuild()
          Does this project perform concurrent builds?
 boolean isConfigurable()
          Used in sidepanel.jelly to decide whether to display the config/delete/build links.
 boolean isDisabled()
           
abstract  boolean isFingerprintConfigured()
          True if the builds of this project produces Fingerprint records.
 boolean isInQueue()
          Returns true if the build is in the queue.
 boolean isParameterized()
           
protected  R loadBuild(File dir)
          Loads an existing build record from disk.
 void makeDisabled(boolean b)
          Marks the build as disabled.
protected  SearchIndexBuilder makeSearchIndex()
          Default implementation that returns empty index.
protected  R newBuild()
          Creates a new build of this project for immediate execution.
 void onCreatedFromScratch()
          When an item is created from scratch (instead of copied), this method will be invoked.
 void onLoad(ItemGroup<? extends Item> parent, String name)
          Called right after when a Item is loaded from disk.
protected  void performDelete()
          Does the real job of deleting the item.
 PollingResult poll(TaskListener listener)
          Checks if there's any update in SCM, and returns true if any is found.
 boolean pollSCMChanges(TaskListener listener)
          Deprecated. as of 1.346 Use poll(TaskListener) instead.
protected
<T extends Describable<T>>
void
removeFromList(Descriptor<T> item, List<T> collection)
           
 void removeRun(R run)
          Called from Run to remove it from this job.
 void removeTrigger(TriggerDescriptor trigger)
           
static AbstractProject resolveForCLI(String name)
          Used for CLI binding.
 void save()
          Save the settings to a file.
 boolean scheduleBuild()
          Deprecated. Use scheduleBuild(Cause). Since 1.283
 boolean scheduleBuild(Cause c)
          Schedules a build of this project.
 boolean scheduleBuild(int quietPeriod)
          Deprecated. Use scheduleBuild(int, Cause). Since 1.283
 boolean scheduleBuild(int quietPeriod, Cause c)
           
 boolean scheduleBuild(int quietPeriod, Cause c, Action... actions)
          Schedules a build.
 QueueTaskFuture<R> scheduleBuild2(int quietPeriod)
          Schedules a build, and returns a Future object to wait for the completion of the build.
 QueueTaskFuture<R> scheduleBuild2(int quietPeriod, Cause c)
          Schedules a build of this project, and returns a Future object to wait for the completion of the build.
 QueueTaskFuture<R> scheduleBuild2(int quietPeriod, Cause c, Action... actions)
          Schedules a build of this project, and returns a Future object to wait for the completion of the build.
 QueueTaskFuture<R> scheduleBuild2(int quietPeriod, Cause c, Collection<? extends Action> actions)
          Schedules a build of this project, and returns a Future object to wait for the completion of the build.
 boolean schedulePolling()
          Schedules a polling of this project.
 void setAssignedLabel(Label l)
          Sets the assigned label.
 void setAssignedNode(Node l)
          Assigns this job to the given node.
 void setBlockBuildWhenDownstreamBuilding(boolean b)
           
 void setBlockBuildWhenUpstreamBuilding(boolean b)
           
 void setConcurrentBuild(boolean b)
           
 void setCustomWorkspace(String customWorkspace)
          User-specified workspace directory, or null if it's up to Jenkins.
 void setJDK(JDK jdk)
          Overwrites the JDK setting.
 void setQuietPeriod(Integer seconds)
          Sets the custom quiet period of this project, or revert to the global default if null is given.
 void setScm(SCM scm)
           
 void setScmCheckoutStrategy(SCMCheckoutStrategy scmCheckoutStrategy)
           
protected  void submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Derived class can override this to perform additional config submission work.
 boolean supportsMakeDisabled()
          Specifies whether this project may be disabled by the user.
protected  void updateTransientActions()
          effectively deprecated.
 
Methods inherited from class hudson.model.Job
assignBuildNumber, delete, doBuildStatus, doDescription, doDoRename, doRssAll, doRssFailed, getACL, getAllJobs, getAllProperties, getBuildDir, getBuildDiscarder, getBuildForCLI, getBuildHealth, getBuildHealthReports, getBuilds, getBuilds, getBuildsAsMap, getBuildsByTimestamp, getBuildStatusUrl, getBuildTimeGraph, getCharacteristicEnvVars, getDynamic, getEstimatedDuration, getLastBuildsOverThreshold, getLastCompletedBuild, getLastFailedBuild, getLastStableBuild, getLastSuccessfulBuild, getLastUnstableBuild, getLastUnsuccessfulBuild, getLogRotator, getNewBuilds, getNextBuildNumber, getOverrides, getPermalinks, getProperties, getProperty, getProperty, getTimeline, getWidgets, isBuilding, isHoldOffBuildUntilSave, isKeepDependencies, isLogUpdated, isNameEditable, logRotate, onCopiedFrom, removeProperty, removeProperty, renameTo, saveNextBuildNumber, setBuildDiscarder, setLogRotator, supportsLogRotator, updateNextBuildNumber
 
Methods inherited from class hudson.model.AbstractItem
checkPermission, delete, doConfigDotXml, doSetName, doSubmitDescription, getAbsoluteUrl, getApi, getConfigFile, getDescription, getDescriptorByName, getDisplayName, getDisplayNameOrNull, getFullDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getRelativeNameFromGroup, getRootDir, getSearchName, getSearchUrl, getShortUrl, getUrl, hasPermission, setDescription, setDisplayName, setDisplayNameOrNull, toString, updateByXml, updateByXml
 
Methods inherited from class hudson.model.Actionable
addAction, doContextMenu, getAction, getAction, getActions
 
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.model.Item
delete, getAbsoluteUrl, getAllJobs, getDisplayName, getFullDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getShortUrl, getUrl, onCopiedFrom
 
Methods inherited from interface hudson.model.PersistenceRoot
getRootDir
 
Methods inherited from interface hudson.search.SearchableModelObject
getSearch
 
Methods inherited from interface hudson.search.SearchItem
getSearchIndex, getSearchName, getSearchUrl
 
Methods inherited from interface hudson.security.AccessControlled
checkPermission, getACL, hasPermission
 
Methods inherited from interface hudson.model.Queue.Task
getFullDisplayName, getName, getUrl
 
Methods inherited from interface hudson.model.queue.SubTask
getEstimatedDuration
 
Methods inherited from interface hudson.model.ResourceActivity
getDisplayName
 

Field Detail

builds

@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class)
protected transient RunMap<R extends AbstractBuild<P,R>> builds
All the builds keyed by their build number. External code should use getBuildByNumber(int) or getLastBuild() and traverse via Run.getPreviousBuild()


disabled

protected volatile boolean disabled
True to suspend new builds.


blockBuildWhenDownstreamBuilding

protected volatile boolean blockBuildWhenDownstreamBuilding
True to keep builds of this project in queue when downstream projects are building. False by default to keep from breaking existing behavior.


blockBuildWhenUpstreamBuilding

protected volatile boolean blockBuildWhenUpstreamBuilding
True to keep builds of this project in queue when upstream projects are building. False by default to keep from breaking existing behavior.


triggers

protected List<Trigger<?>> triggers
List of all Triggers for this project.


transientActions

@CopyOnWrite
protected transient volatile List<Action> transientActions
Actions contributed from subsidiary objects associated with AbstractProject, such as from triggers, builders, publishers, etc. We don't want to persist them separately, and these actions come and go as configuration change, so it's kept separate.


ABORT

public static final Permission ABORT
Permission to abort a build


BUILD_NOW_TEXT

public static final AlternativeUiTextProvider.Message<AbstractProject> BUILD_NOW_TEXT
Replaceable "Build Now" text.

Constructor Detail

AbstractProject

protected AbstractProject(ItemGroup parent,
                          String name)
Method Detail

save

public void save()
          throws IOException
Description copied from class: AbstractItem
Save the settings to a file.

Specified by:
save in interface Item
Specified by:
save in interface Saveable
Overrides:
save in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
Throws:
IOException - if the persistence failed.

onCreatedFromScratch

public void onCreatedFromScratch()
Description copied from interface: Item
When an item is created from scratch (instead of copied), this method will be invoked. Used as the post-construction initialization.

Specified by:
onCreatedFromScratch in interface Item
Overrides:
onCreatedFromScratch in class AbstractItem

onLoad

public void onLoad(ItemGroup<? extends Item> parent,
                   String name)
            throws IOException
Description copied from class: AbstractItem
Called right after when a Item is loaded from disk. This is an opporunity to do a post load processing.

Specified by:
onLoad in interface Item
Overrides:
onLoad in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
name - Name of the directory (not a path --- just the name portion) from which the configuration was loaded. This usually becomes the name of this item.
Throws:
IOException

getEnvironment

public EnvVars getEnvironment(Node node,
                              TaskListener listener)
                       throws IOException,
                              InterruptedException
Description copied from class: Job
Creates an environment variable override for launching processes for this project.

This is for process launching outside the build execution (such as polling, tagging, deployment, etc.) that happens in a context of a specific job.

Overrides:
getEnvironment in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
Parameters:
node - Node to eventually run a process on. The implementation must cope with this parameter being null (in which case none of the node specific properties would be reflected in the resulting override.)
Throws:
IOException
InterruptedException

performDelete

protected void performDelete()
                      throws IOException,
                             InterruptedException
Description copied from class: AbstractItem
Does the real job of deleting the item.

Overrides:
performDelete in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
Throws:
IOException
InterruptedException

isConcurrentBuild

@Exported
public boolean isConcurrentBuild()
Does this project perform concurrent builds?

Specified by:
isConcurrentBuild in interface Queue.Task
Since:
1.319

setConcurrentBuild

public void setConcurrentBuild(boolean b)
                        throws IOException
Throws:
IOException

getAssignedLabel

public Label getAssignedLabel()
If this project is configured to be always built on this node, return that Node. Otherwise null.

Specified by:
getAssignedLabel in interface SubTask

getRelevantLabels

public Set<Label> getRelevantLabels()
Set of labels relevant to this job. This method is used to determine what slaves are relevant to jobs, for example by Views. It does not affect the scheduling. This information is informational and the best-effort basis.

Returns:
Minimally it should contain getAssignedLabel(). The set can contain null element to correspond to the null return value from getAssignedLabel().
Since:
1.456

getAssignedLabelString

public String getAssignedLabelString()
Gets the textual representation of the assigned label as it was entered by the user.


setAssignedLabel

public void setAssignedLabel(Label l)
                      throws IOException
Sets the assigned label.

Throws:
IOException

setAssignedNode

public void setAssignedNode(Node l)
                     throws IOException
Assigns this job to the given node. A convenience method over setAssignedLabel(Label).

Throws:
IOException

getPronoun

public String getPronoun()
Get the term used in the UI to represent this kind of AbstractProject. Must start with a capital letter.

Overrides:
getPronoun in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getBuildNowText

public String getBuildNowText()
Gets the human readable display name to be rendered in the "Build Now" link.

Since:
1.401

getRootProject

public AbstractProject<?,?> getRootProject()
Gets the nearest ancestor TopLevelItem that's also an AbstractProject.

Some projects (such as matrix projects, Maven projects, or promotion processes) form a tree of jobs that acts as a single unit. This method can be used to find the top most dominating job that covers such a tree.

Returns:
never null.
See Also:
AbstractBuild.getRootBuild()

getWorkspace

public final FilePath getWorkspace()
Deprecated. as of 1.319 To support concurrent builds of the same project, this method is moved to AbstractBuild. For backward compatibility, this method returns the right AbstractBuild.getWorkspace() if called from Executor, and otherwise the workspace of the last build.

If you are calling this method during a build from an executor, switch it to AbstractBuild.getWorkspace(). If you are calling this method to serve a file from the workspace, doing a form validation, etc., then use getSomeWorkspace()

Gets the directory where the module is checked out.

Returns:
null if the workspace is on a slave that's not connected.

getSomeWorkspace

public final FilePath getSomeWorkspace()
Gets a workspace for some build of this project.

This is useful for obtaining a workspace for the purpose of form field validation, where exactly which build the workspace belonged is less important. The implementation makes a cursory effort to find some workspace.

Returns:
null if there's no available workspace.
Since:
1.319

getSomeBuildWithWorkspace

public final R getSomeBuildWithWorkspace()
Gets some build that has a live workspace.

Returns:
null if no such build exists.

getModuleRoot

public FilePath getModuleRoot()
Deprecated. as of 1.319 See getWorkspace() for a migration strategy.

Returns the root directory of the checked-out module.

This is usually where pom.xml, build.xml and so on exists.


getModuleRoots

public FilePath[] getModuleRoots()
Deprecated. as of 1.319 See getWorkspace() for a migration strategy.

Returns the root directories of all checked-out modules.

Some SCMs support checking out multiple modules into the same workspace. In these cases, the returned array will have a length greater than one.

Returns:
The roots of all modules checked out from the SCM.

getQuietPeriod

public int getQuietPeriod()

getScmCheckoutStrategy

public SCMCheckoutStrategy getScmCheckoutStrategy()

setScmCheckoutStrategy

public void setScmCheckoutStrategy(SCMCheckoutStrategy scmCheckoutStrategy)
                            throws IOException
Throws:
IOException

getScmCheckoutRetryCount

public int getScmCheckoutRetryCount()

getHasCustomQuietPeriod

public boolean getHasCustomQuietPeriod()

setQuietPeriod

public void setQuietPeriod(Integer seconds)
                    throws IOException
Sets the custom quiet period of this project, or revert to the global default if null is given.

Throws:
IOException

hasCustomScmCheckoutRetryCount

public boolean hasCustomScmCheckoutRetryCount()

isBuildable

public boolean isBuildable()
Description copied from class: Job
Returns true if we should display "build now" icon

Specified by:
isBuildable in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

isConfigurable

public boolean isConfigurable()
Used in sidepanel.jelly to decide whether to display the config/delete/build links.


blockBuildWhenDownstreamBuilding

public boolean blockBuildWhenDownstreamBuilding()

setBlockBuildWhenDownstreamBuilding

public void setBlockBuildWhenDownstreamBuilding(boolean b)
                                         throws IOException
Throws:
IOException

blockBuildWhenUpstreamBuilding

public boolean blockBuildWhenUpstreamBuilding()

setBlockBuildWhenUpstreamBuilding

public void setBlockBuildWhenUpstreamBuilding(boolean b)
                                       throws IOException
Throws:
IOException

isDisabled

public boolean isDisabled()

doCheckRetryCount

public FormValidation doCheckRetryCount(@QueryParameter
                                        String value)
                                 throws IOException,
                                        javax.servlet.ServletException
Validates the retry count Regex

Throws:
IOException
javax.servlet.ServletException

makeDisabled

public void makeDisabled(boolean b)
                  throws IOException
Marks the build as disabled.

Throws:
IOException

supportsMakeDisabled

public boolean supportsMakeDisabled()
Specifies whether this project may be disabled by the user. By default, it can be only if this is a TopLevelItem; would be false for matrix configurations, etc.

Returns:
true if the GUI should allow doDisable() and the like
Since:
1.475

disable

public void disable()
             throws IOException
Throws:
IOException

enable

public void enable()
            throws IOException
Throws:
IOException

getIconColor

public BallColor getIconColor()
Description copied from class: Job
Used as the color of the status ball for the project.

Overrides:
getIconColor in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

updateTransientActions

protected void updateTransientActions()
effectively deprecated. Since using updateTransientActions correctly under concurrent environment requires a lock that can too easily cause deadlocks.

Override createTransientActions() instead.


createTransientActions

protected List<Action> createTransientActions()

getPublishersList

public abstract DescribableList<Publisher,Descriptor<Publisher>> getPublishersList()
Returns the live list of all Publishers configured for this project.

This method couldn't be called getPublishers() because existing methods in sub-classes return different inconsistent types.


addProperty

public void addProperty(JobProperty<? super P> jobProp)
                 throws IOException
Description copied from class: Job
Adds JobProperty.

Overrides:
addProperty in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
Throws:
IOException

getProminentActions

public List<ProminentProjectAction> getProminentActions()

doConfigSubmit

public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req,
                           org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException,
                           javax.servlet.ServletException,
                           Descriptor.FormException
Description copied from class: Job
Accepts submission from the configuration page.

Overrides:
doConfigSubmit in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException

scheduleBuild

public boolean scheduleBuild()
Deprecated. Use scheduleBuild(Cause). Since 1.283

Specified by:
scheduleBuild in interface BuildableItem

scheduleBuild

public boolean scheduleBuild(int quietPeriod)
Deprecated. Use scheduleBuild(int, Cause). Since 1.283

Specified by:
scheduleBuild in interface BuildableItem

scheduleBuild

public boolean scheduleBuild(Cause c)
Schedules a build of this project.

Specified by:
scheduleBuild in interface BuildableItem
Returns:
true if the project is actually added to the queue. false if the queue contained it and therefore the add() was noop

scheduleBuild

public boolean scheduleBuild(int quietPeriod,
                             Cause c)
Specified by:
scheduleBuild in interface BuildableItem

scheduleBuild

public boolean scheduleBuild(int quietPeriod,
                             Cause c,
                             Action... actions)
Schedules a build. Important: the actions should be persistable without outside references (e.g. don't store references to this project). To provide parameters for a parameterized project, add a ParametersAction. If no ParametersAction is provided for such a project, one will be created with the default parameter values.

Parameters:
quietPeriod - the quiet period to observer
c - the cause for this build which should be recorded
actions - a list of Actions that will be added to the build
Returns:
whether the build was actually scheduled

scheduleBuild2

@WithBridgeMethods(value=java.util.concurrent.Future.class)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod,
                                                                                            Cause c,
                                                                                            Action... actions)
Schedules a build of this project, and returns a Future object to wait for the completion of the build.

Parameters:
actions - For the convenience of the caller, this array can contain null, and those will be silently ignored.

scheduleBuild2

@WithBridgeMethods(value=java.util.concurrent.Future.class)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod,
                                                                                            Cause c,
                                                                                            Collection<? extends Action> actions)
Schedules a build of this project, and returns a Future object to wait for the completion of the build.

Parameters:
actions - For the convenience of the caller, this collection can contain null, and those will be silently ignored.
Since:
1.383

scheduleBuild2

@WithBridgeMethods(value=java.util.concurrent.Future.class)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod)
Schedules a build, and returns a Future object to wait for the completion of the build.

Production code shouldn't be using this, but for tests this is very convenient, so this isn't marked as deprecated.


scheduleBuild2

@WithBridgeMethods(value=java.util.concurrent.Future.class)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod,
                                                                                            Cause c)
Schedules a build of this project, and returns a Future object to wait for the completion of the build.


schedulePolling

public boolean schedulePolling()
Schedules a polling of this project.


isInQueue

public boolean isInQueue()
Returns true if the build is in the queue.

Overrides:
isInQueue in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getQueueItem

public Queue.Item getQueueItem()
Description copied from class: Job
If this job is in the build queue, return its item.

Overrides:
getQueueItem in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getJDK

public JDK getJDK()
Gets the JDK that this project is configured with, or null.


setJDK

public void setJDK(JDK jdk)
            throws IOException
Overwrites the JDK setting.

Throws:
IOException

getAuthToken

public BuildAuthorizationToken getAuthToken()

_getRuns

public RunMap<R> _getRuns()
Description copied from class: Job
Gets all the runs. The resulting map must be treated immutable (by employing copy-on-write semantics.) The map is descending order, with newest builds at the top.

Specified by:
_getRuns in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

removeRun

public void removeRun(R run)
Description copied from class: Job
Called from Run to remove it from this job. The files are deleted already. So all the callee needs to do is to remove a reference from this Job.

Specified by:
removeRun in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getBuild

public R getBuild(String id)
More efficient implementation.

Overrides:
getBuild in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getBuildByNumber

public R getBuildByNumber(int n)
More efficient implementation.

Overrides:
getBuildByNumber in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
Parameters:
n - The build number.
Returns:
null if no such build exists.
See Also:
Run.getNumber()

getFirstBuild

public R getFirstBuild()
Returns the oldest build in the record. More efficient implementation.

Overrides:
getFirstBuild in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getLastBuild

public R getLastBuild()
Description copied from class: Job
Returns the last build.

Overrides:
getLastBuild in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getNearestBuild

public R getNearestBuild(int n)
Description copied from class: Job
Gets the youngest build #m that satisfies n<=m. This is useful when you'd like to fetch a build but the exact build might be already gone (deleted, rotated, etc.)

Overrides:
getNearestBuild in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getNearestOldBuild

public R getNearestOldBuild(int n)
Description copied from class: Job
Gets the latest build #m that satisfies m<=n. This is useful when you'd like to fetch a build but the exact build might be already gone (deleted, rotated, etc.)

Overrides:
getNearestOldBuild in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

getBuildClass

protected abstract Class<R> getBuildClass()
Determines Class<R>.


newBuild

protected R newBuild()
                                         throws IOException
Creates a new build of this project for immediate execution.

Throws:
IOException

loadBuild

protected R loadBuild(File dir)
                                          throws IOException
Loads an existing build record from disk.

Throws:
IOException

getActions

public List<Action> getActions()
Gets actions contributed to this build.

A new Action can be added by getActions().add(...).

Note that this method returns a read-only view of Actions. BuildSteps and others who want to add a project action should do so by implementing BuildStep.getProjectActions(AbstractProject).

Overrides:
getActions in class Actionable
Returns:
may be empty but never null.
See Also:
TransientProjectActionFactory

getLastBuiltOn

public Node getLastBuiltOn()
Gets the Node where this project was last built on.

Specified by:
getLastBuiltOn in interface SubTask
Returns:
null if no information is available (for example, if no build was done yet.)

getSameNodeConstraint

public Object getSameNodeConstraint()
Description copied from interface: SubTask
If a subset of SubTasks of a Queue.Task needs to be collocated with other SubTasks, those SubTasks should return the equal object here. If null, the execution unit isn't under a colocation constraint.

Specified by:
getSameNodeConstraint in interface SubTask

getOwnerTask

public final Queue.Task getOwnerTask()
Description copied from interface: SubTask
Gets the Queue.Task that this subtask belongs to.

Specified by:
getOwnerTask in interface SubTask

isBuildBlocked

public boolean isBuildBlocked()
Returns true if the execution should be blocked for temporary reasons.

Short-hand for getCauseOfBlockage()!=null.

A project must be blocked if its own previous build is in progress, or if the blockBuildWhenUpstreamBuilding option is true and an upstream project is building, but derived classes can also check other conditions.

Specified by:
isBuildBlocked in interface Queue.Task

getWhyBlocked

public String getWhyBlocked()
Specified by:
getWhyBlocked in interface Queue.Task

getCauseOfBlockage

public CauseOfBlockage getCauseOfBlockage()
Description copied from interface: Queue.Task
If the execution of this task should be blocked for temporary reasons, this method returns a non-null object explaining why.

Otherwise this method returns null, indicating that the build can proceed right away.

This can be used to define mutual exclusion that goes beyond ResourceActivity.getResourceList().

Specified by:
getCauseOfBlockage in interface Queue.Task

getBuildingDownstream

public AbstractProject getBuildingDownstream()
Returns the project if any of the downstream project is either building, waiting, pending or buildable.

This means eventually there will be an automatic triggering of the given project (provided that all builds went smoothly.)


getBuildingUpstream

public AbstractProject getBuildingUpstream()
Returns the project if any of the upstream project is either building or is in the queue.

This means eventually there will be an automatic triggering of the given project (provided that all builds went smoothly.)


getSubTasks

public List<SubTask> getSubTasks()
Description copied from interface: Queue.Task
Obtains the SubTasks that constitute this task.

The collection returned by this method must also contain the primary SubTask represented by this Queue.TransientTask object itself as the first element. The returned value is read-only.

At least size 1.

Since this is a newly added method, the invocation may results in AbstractMethodError. Use Tasks#getSubTasksOf(Task) that avoids this.

Specified by:
getSubTasks in interface Queue.Task

createExecutable

public R createExecutable()
                                              throws IOException
Description copied from interface: SubTask
Creates Queue.Executable, which performs the actual execution of the task.

Specified by:
createExecutable in interface SubTask
Throws:
IOException

checkAbortPermission

public void checkAbortPermission()
Description copied from interface: Queue.Task
Checks the permission to see if the current user can abort this executable. Returns normally from this method if it's OK.

Specified by:
checkAbortPermission in interface Queue.Task

hasAbortPermission

public boolean hasAbortPermission()
Description copied from interface: Queue.Task
Works just like Queue.Task.checkAbortPermission() except it indicates the status by a return value, instead of exception.

Specified by:
hasAbortPermission in interface Queue.Task

getWorkspaceResource

public Resource getWorkspaceResource()
Deprecated. as of 1.319 Projects no longer have a fixed workspace, ands builds will find an available workspace via WorkspaceList for each build (furthermore, that happens after a build is started.) So a Resource representation for a workspace at the project level no longer makes sense.

If you need to lock a workspace while you do some computation, see the source code of pollSCMChanges(TaskListener) for how to obtain a lock of a workspace through WorkspaceList.

Gets the Resource that represents the workspace of this project. Useful for locking and mutual exclusion control.


getResourceList

public ResourceList getResourceList()
List of necessary resources to perform the build of this project.

Specified by:
getResourceList in interface ResourceActivity
Returns:
never null

getResourceActivities

protected Set<ResourceActivity> getResourceActivities()
Set of child resource activities of the build of this project (override in child projects).

Returns:
The set of child resource activities of the build of this project.

checkout

public boolean checkout(AbstractBuild build,
                        Launcher launcher,
                        BuildListener listener,
                        File changelogFile)
                 throws IOException,
                        InterruptedException
Throws:
IOException
InterruptedException

pollSCMChanges

public boolean pollSCMChanges(TaskListener listener)
Deprecated. as of 1.346 Use poll(TaskListener) instead.

Checks if there's any update in SCM, and returns true if any is found.


poll

public PollingResult poll(TaskListener listener)
Checks if there's any update in SCM, and returns true if any is found.

The implementation is responsible for ensuring mutual exclusion between polling and builds if necessary.

Since:
1.345

hasParticipant

public boolean hasParticipant(User user)
Returns true if this user has made a commit to this project.

Since:
1.191

getScm

@Exported
public SCM getScm()

setScm

public void setScm(SCM scm)
            throws IOException
Throws:
IOException

addTrigger

public void addTrigger(Trigger<?> trigger)
                throws IOException
Adds a new Trigger to this Project if not active yet.

Throws:
IOException

removeTrigger

public void removeTrigger(TriggerDescriptor trigger)
                   throws IOException
Throws:
IOException

addToList

protected final <T extends Describable<T>> void addToList(T item,
                                                          List<T> collection)
                        throws IOException
Throws:
IOException

removeFromList

protected final <T extends Describable<T>> void removeFromList(Descriptor<T> item,
                                                               List<T> collection)
                             throws IOException
Throws:
IOException

getTriggers

public Map<TriggerDescriptor,Trigger> getTriggers()

getTrigger

public <T extends Trigger> T getTrigger(Class<T> clazz)
Gets the specific trigger, or null if the propert is not configured for this job.


isFingerprintConfigured

public abstract boolean isFingerprintConfigured()
True if the builds of this project produces Fingerprint records.


getDownstreamProjects

@Exported
public final List<AbstractProject> getDownstreamProjects()
Gets the other AbstractProjects that should be built when a build of this project is completed.


getUpstreamProjects

@Exported
public final List<AbstractProject> getUpstreamProjects()

getBuildTriggerUpstreamProjects

public final List<AbstractProject> getBuildTriggerUpstreamProjects()
Returns only those upstream projects that defines BuildTrigger to this project. This is a subset of getUpstreamProjects()

Returns:
A List of upstream projects that has a BuildTrigger to this project.

getTransitiveUpstreamProjects

public final Set<AbstractProject> getTransitiveUpstreamProjects()
Gets all the upstream projects including transitive upstream projects.

Since:
1.138

getTransitiveDownstreamProjects

public final Set<AbstractProject> getTransitiveDownstreamProjects()
Gets all the downstream projects including transitive downstream projects.

Since:
1.138

getRelationship

public SortedMap<Integer,Fingerprint.RangeSet> getRelationship(AbstractProject that)
Gets the dependency relationship map between this project (as the source) and that project (as the sink.)

Returns:
can be empty but not null. build number of this project to the build numbers of that project.

buildDependencyGraph

protected abstract void buildDependencyGraph(DependencyGraph graph)
Builds the dependency graph.

See Also:
DependencyGraph

makeSearchIndex

protected SearchIndexBuilder makeSearchIndex()
Description copied from class: AbstractModelObject
Default implementation that returns empty index.

Overrides:
makeSearchIndex in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

createHistoryWidget

protected HistoryWidget createHistoryWidget()
Overrides:
createHistoryWidget in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>

isParameterized

public boolean isParameterized()

doBuild

public void doBuild(org.kohsuke.stapler.StaplerRequest req,
                    org.kohsuke.stapler.StaplerResponse rsp,
                    @QueryParameter
                    TimeDuration delay)
             throws IOException,
                    javax.servlet.ServletException
Schedules a new build command.

Throws:
IOException
javax.servlet.ServletException

getDelay

public int getDelay(org.kohsuke.stapler.StaplerRequest req)
             throws javax.servlet.ServletException
Deprecated. as of 1.488 Inject TimeDuration.

Computes the delay by taking the default value and the override in the request parameter into the account.

Throws:
javax.servlet.ServletException

doBuildWithParameters

public void doBuildWithParameters(org.kohsuke.stapler.StaplerRequest req,
                                  org.kohsuke.stapler.StaplerResponse rsp,
                                  @QueryParameter
                                  TimeDuration delay)
                           throws IOException,
                                  javax.servlet.ServletException
Supports build trigger with parameters via an HTTP GET or POST. Currently only String parameters are supported.

Throws:
IOException
javax.servlet.ServletException

doPolling

public void doPolling(org.kohsuke.stapler.StaplerRequest req,
                      org.kohsuke.stapler.StaplerResponse rsp)
               throws IOException,
                      javax.servlet.ServletException
Schedules a new SCM polling command.

Throws:
IOException
javax.servlet.ServletException

doCancelQueue

public void doCancelQueue(org.kohsuke.stapler.StaplerRequest req,
                          org.kohsuke.stapler.StaplerResponse rsp)
                   throws IOException,
                          javax.servlet.ServletException
Cancels a scheduled build.

Throws:
IOException
javax.servlet.ServletException

doDoDelete

public void doDoDelete(org.kohsuke.stapler.StaplerRequest req,
                       org.kohsuke.stapler.StaplerResponse rsp)
                throws IOException,
                       javax.servlet.ServletException,
                       InterruptedException
Deletes this project.

Overrides:
doDoDelete in class AbstractItem
Throws:
IOException
javax.servlet.ServletException
InterruptedException

submit

protected void submit(org.kohsuke.stapler.StaplerRequest req,
                      org.kohsuke.stapler.StaplerResponse rsp)
               throws IOException,
                      javax.servlet.ServletException,
                      Descriptor.FormException
Description copied from class: Job
Derived class can override this to perform additional config submission work.

Overrides:
submit in class Job<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>>
Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException

buildDescribable

protected final <T extends Describable<T>> List<T> buildDescribable(org.kohsuke.stapler.StaplerRequest req,
                                                                    List<? extends Descriptor<T>> descriptors,
                                                                    String prefix)
                                                         throws Descriptor.FormException,
                                                                javax.servlet.ServletException
Deprecated. As of 1.261. Use buildDescribable(StaplerRequest, List) instead.

Throws:
Descriptor.FormException
javax.servlet.ServletException

buildDescribable

protected final <T extends Describable<T>> List<T> buildDescribable(org.kohsuke.stapler.StaplerRequest req,
                                                                    List<? extends Descriptor<T>> descriptors)
                                                         throws Descriptor.FormException,
                                                                javax.servlet.ServletException
Throws:
Descriptor.FormException
javax.servlet.ServletException

doWs

public DirectoryBrowserSupport doWs(org.kohsuke.stapler.StaplerRequest req,
                                    org.kohsuke.stapler.StaplerResponse rsp)
                             throws IOException,
                                    javax.servlet.ServletException,
                                    InterruptedException
Serves the workspace files.

Throws:
IOException
javax.servlet.ServletException
InterruptedException

doDoWipeOutWorkspace

public org.kohsuke.stapler.HttpResponse doDoWipeOutWorkspace()
                                                      throws IOException,
                                                             javax.servlet.ServletException,
                                                             InterruptedException
Wipes out the workspace.

Throws:
IOException
javax.servlet.ServletException
InterruptedException

doDisable

@CLIMethod(name="disable-job")
public org.kohsuke.stapler.HttpResponse doDisable()
                                           throws IOException,
                                                  javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doEnable

@CLIMethod(name="enable-job")
public org.kohsuke.stapler.HttpResponse doEnable()
                                          throws IOException,
                                                 javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doRssChangelog

public void doRssChangelog(org.kohsuke.stapler.StaplerRequest req,
                           org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException,
                           javax.servlet.ServletException
RSS feed for changes in this project.

Throws:
IOException
javax.servlet.ServletException

findNearest

public static AbstractProject findNearest(String name)
Finds a AbstractProject that has the name closest to the given name.


findNearest

public static AbstractProject findNearest(String name,
                                          ItemGroup context)
Finds a AbstractProject whose name (when referenced from the specified context) is closest to the given name.

Since:
1.419

resolveForCLI

@CLIResolver
public static AbstractProject resolveForCLI(String name)
                                     throws org.kohsuke.args4j.CmdLineException
Used for CLI binding.

Throws:
org.kohsuke.args4j.CmdLineException

getCustomWorkspace

public String getCustomWorkspace()

setCustomWorkspace

public void setCustomWorkspace(String customWorkspace)
                        throws IOException
User-specified workspace directory, or null if it's up to Jenkins.

Normally a project uses the workspace location assigned by its parent container, but sometimes people have builds that have hard-coded paths.

This is not File because it may have to hold a path representation on another OS.

If this path is relative, it's resolved against Node.getRootPath() on the node where this workspace is prepared.

Throws:
IOException
Since:
1.410


Copyright © 2004-2013. All Rights Reserved.