Package jenkins.model

Class Jenkins

    • Field Detail

      • lookup

        public final transient Lookup lookup
        Stores various objects scoped to Jenkins.
      • root

        public final transient File root
        Root directory of the system.
      • slaves

        @Deprecated
        protected transient volatile NodeList slaves
        Deprecated.
        in favour of Nodes
        Legacy store of the set of installed cluster nodes.
      • pluginManager

        public final transient PluginManager pluginManager
        Loaded plugins.
      • overallLoad

        @Exported
        public final transient OverallLoadStatistics overallLoad
        Load statistics of the entire system. This includes every executor and every job in the system.
      • unlabeledLoad

        @Exported
        public final transient LoadStatistics unlabeledLoad
        Load statistics of the free roaming jobs and agents. This includes all executors on Node.Mode.NORMAL nodes and jobs that do not have any assigned nodes.
        Since:
        1.467
      • overallNodeProvisioner

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        @Deprecated
        public final transient NodeProvisioner overallNodeProvisioner
        Deprecated.
        as of 1.467 Use unlabeledNodeProvisioner. This was broken because it was tracking all the executors in the system, but it was only tracking free-roaming jobs in the queue. So Cloud fails to launch nodes when you have some exclusive agents and free-roaming jobs in the queue.
      • servletContext

        public final transient javax.servlet.ServletContext servletContext
      • XSTREAM

        public static final com.thoughtworks.xstream.XStream XSTREAM
        Thread-safe reusable XStream.
      • XSTREAM2

        public static final XStream2 XSTREAM2
        Alias to XSTREAM so that one can access additional methods on XStream2 more easily.
      • UNCOMPUTED_VERSION

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static final String UNCOMPUTED_VERSION
        The version number before it is "computed" (by a call to computeVersion()).
        Since:
        2.0
        See Also:
        Constant Field Values
      • VERSION

        public static String VERSION
        Version number of this Jenkins.
      • CHANGELOG_URL

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static String CHANGELOG_URL
      • VERSION_HASH

        public static String VERSION_HASH
        Hash of VERSION.
      • SESSION_HASH

        public static String SESSION_HASH
        Unique random token that identifies the current session. Used to make RESOURCE_PATH unique so that we can set long "Expires" header. We used to use VERSION_HASH, but making this session local allows us to reuse the same RESOURCE_PATH for static resources in plugins.
      • RESOURCE_PATH

        public static String RESOURCE_PATH
        Prefix to static resources like images and javascripts in the war file. Either "" or strings like "/static/VERSION", which avoids Jenkins to pick up stale cache when the user upgrades to a different version.

        Value computed in WebAppMain.

      • VIEW_RESOURCE_PATH

        public static String VIEW_RESOURCE_PATH
        Prefix to resources alongside view scripts. Strings like "/resources/VERSION", which avoids Jenkins to pick up stale cache when the user upgrades to a different version.

        Value computed in WebAppMain.

      • PARALLEL_LOAD

        public static boolean PARALLEL_LOAD
      • KILL_AFTER_LOAD

        public static boolean KILL_AFTER_LOAD
      • FLYWEIGHT_SUPPORT

        @Deprecated
        public static boolean FLYWEIGHT_SUPPORT
        Deprecated.
        No longer used.
      • CONCURRENT_BUILD

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        @Deprecated
        public static boolean CONCURRENT_BUILD
        Deprecated.
        as of 1.464 This flag will have no effect.
        Tentative switch to activate the concurrent build behavior. When we merge this back to the trunk, this allows us to keep this feature hidden for a while until we iron out the kinks.
        See Also:
        AbstractProject.isConcurrentBuild()
      • NAME_VALIDATION_REJECTS_TRAILING_DOT_PROP

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static final String NAME_VALIDATION_REJECTS_TRAILING_DOT_PROP
        Name of the system property escape hatch for SECURITY-2424. It allows to have back the legacy (and vulnerable) behavior allowing a "good name" to end with a dot. This could be used to exploit two names colliding in the file system to extract information. The files ending with a dot are only a problem on Windows. The default value is true. For detailed documentation: Support for Whitespace characters in File and Folder names for Windows
        See Also:
        checkGoodName(String)
      • AUTOMATIC_AGENT_LAUNCH

        public static boolean AUTOMATIC_AGENT_LAUNCH
        Automatically try to launch an agent when Jenkins is initialized or a new agent computer is created.
      • EXTEND_TIMEOUT_SECONDS

        public static int EXTEND_TIMEOUT_SECONDS
        The amount of time by which to extend the startup notification timeout as each initialization milestone is attained.
      • ADMINISTER

        public static final Permission ADMINISTER
      • MANAGE

        @Restricted(org.kohsuke.accmod.restrictions.Beta.class)
        public static final Permission MANAGE
        This permission grants access to parts of the Jenkins system configuration.

        Only features that won't have an impact on Jenkins' overall security and stability should have their permission requirement lowered from ADMINISTER to MANAGE. For example, many scripting and code execution features (e.g., configuring master agents, paths to tools on master, etc.) are unsafe to make available to users with only this permission, as they could be used to bypass permission enforcement and elevate permissions.

        This permission is disabled by default and support for it considered experimental. Administrators can set the system property jenkins.security.ManagePermission to enable it.

        Since:
        2.222
      • SYSTEM_READ

        public static final Permission SYSTEM_READ
        Allows read-only access to large parts of the system configuration. When combined with MANAGE, it is expected that everything is shown as if only SYSTEM_READ was granted, but that only options editable by users with MANAGE are editable.
      • MANAGE_AND_SYSTEM_READ

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static final Permission[] MANAGE_AND_SYSTEM_READ
      • ANONYMOUS2

        public static final org.springframework.security.core.Authentication ANONYMOUS2
        Authentication object that represents the anonymous user. Because Spring Security creates its own AnonymousAuthenticationToken instances, the code must not expect the singleton semantics. This is just a convenient instance.
        Since:
        2.266
    • Method Detail

      • getInstanceOrNull

        @CLIResolver
        @CheckForNull
        public static Jenkins getInstanceOrNull()
        Gets the Jenkins singleton. get() is what you normally want.

        In certain rare cases you may have code that is intended to run before Jenkins starts or while Jenkins is being shut down. For those rare cases use this method.

        In other cases you may have code that might end up running on a remote JVM and not on the Jenkins controller or built-in node. For those cases you really should rewrite your code so that when the Callable is sent over the remoting channel it can do whatever it needs without ever referring to Jenkins; for example, gather any information you need on the controller side before constructing the callable. If you must do a runtime check whether you are in the controller or agent, use JenkinsJVM rather than this method, as merely loading the Jenkins class file into an agent JVM can cause linkage errors under some conditions.

        Returns:
        The instance. Null if the Jenkins service has not been started, or was already shut down, or we are running on an unrelated JVM, typically an agent.
        Since:
        1.653
      • readResolve

        protected Object readResolve()
        Maintains backwards compatibility. Invoked by XStream when this object is de-serialized.
      • getProxy

        @CheckForNull
        public ProxyConfiguration getProxy()
        Retrieve the proxy configuration.
        Returns:
        the proxy configuration
        Since:
        2.205
      • setProxy

        public void setProxy​(@CheckForNull
                             ProxyConfiguration proxy)
        Set the proxy configuration.
        Parameters:
        proxy - the proxy to set
        Since:
        2.205
      • setInstallState

        public void setInstallState​(@NonNull
                                    InstallState newState)
        Update the current install state. This will invoke state.initializeState() when the state has been transitioned.
      • getAdjuncts

        public org.kohsuke.stapler.framework.adjunct.AdjunctManager getAdjuncts​(String dummy)
        Makes AdjunctManager URL-bound. The dummy parameter allows us to use different URLs for the same adjunct, for proper cache handling.
      • getSlaveAgentPort

        @Exported
        public int getSlaveAgentPort()
      • isSlaveAgentPortEnforced

        public boolean isSlaveAgentPortEnforced()
        Since:
        2.24
      • setSlaveAgentPort

        public void setSlaveAgentPort​(int port)
                               throws IOException
        Parameters:
        port - 0 to indicate random available TCP port. -1 to disable this service.
        Throws:
        IOException
      • getAgentProtocols

        @NonNull
        public Set<String> getAgentProtocols()
        Returns the enabled agent protocols.
        Returns:
        the enabled agent protocols.
        Since:
        2.16
      • setAgentProtocols

        public void setAgentProtocols​(@NonNull
                                      Set<String> protocols)
        Sets the enabled agent protocols.
        Parameters:
        protocols - the enabled agent protocols.
        Since:
        2.16
      • setNodeName

        public void setNodeName​(String name)
        Description copied from class: Node
        When the user clones a Node, Hudson uses this method to change the node name right after the cloned Node object is instantiated.

        This method is never used for any other purpose, and as such for all practical intents and purposes, the node name should be treated like immutable.

        Specified by:
        setNodeName in class Node
      • getNodeDescription

        public String getNodeDescription()
        Description copied from class: Node
        Human-readable description of this node.
        Specified by:
        getNodeDescription in class Node
      • getDescription

        @Exported
        public String getDescription()
      • getPluginManager

        @NonNull
        public PluginManager getPluginManager()
      • isNoUsageStatistics

        @CheckForNull
        public Boolean isNoUsageStatistics()
        If usage statistics has been disabled
        Since:
        2.226
      • isUsageStatisticsCollected

        public boolean isUsageStatisticsCollected()
        If usage statistics are being collected
        Returns:
        true if usage statistics should be collected. Defaults to true when noUsageStatistics is not set.
      • setNoUsageStatistics

        public void setNoUsageStatistics​(Boolean noUsageStatistics)
                                  throws IOException
        Sets the noUsageStatistics flag
        Throws:
        IOException
      • hasPeople

        @Deprecated
        public boolean hasPeople()
        Deprecated.
        Potentially very expensive call; do not use from Jelly views.
        Does this View has any associated user information recorded?
      • getApi

        public Api getApi()
      • getSecretKey

        @Deprecated
        public String getSecretKey()
        Deprecated.
        Due to the past security advisory, this value should not be used any more to protect sensitive information. See ConfidentialStore and ConfidentialKey for how to store secrets.
        Returns a secret key that survives across container start/stop.

        This value is useful for implementing some of the security features.

      • getLegacyInstanceId

        public String getLegacyInstanceId()
        Returns the unique identifier of this Jenkins that has been historically used to identify this Jenkins to the outside world.

        This form of identifier is weak in that it can be impersonated by others. See the Instance Identity plugin for more modern form of instance ID that can be challenged and verified.

        Since:
        1.498
      • getScm

        public Descriptor<SCM> getScm​(String shortClassName)
        Gets the SCM descriptor by name. Primarily used for making them web-visible.
      • getRepositoryBrowser

        public Descriptor<RepositoryBrowser<?>> getRepositoryBrowser​(String shortClassName)
        Gets the repository browser descriptor by name. Primarily used for making them web-visible.
      • getBuilder

        public Descriptor<Builder> getBuilder​(String shortClassName)
        Gets the builder descriptor by name. Primarily used for making them web-visible.
      • getBuildWrapper

        public Descriptor<BuildWrapper> getBuildWrapper​(String shortClassName)
        Gets the build wrapper descriptor by name. Primarily used for making them web-visible.
      • getPublisher

        public Descriptor<Publisher> getPublisher​(String shortClassName)
        Gets the publisher descriptor by name. Primarily used for making them web-visible.
      • getTrigger

        public TriggerDescriptor getTrigger​(String shortClassName)
        Gets the trigger descriptor by name. Primarily used for making them web-visible.
      • getRetentionStrategy

        public Descriptor<RetentionStrategy<?>> getRetentionStrategy​(String shortClassName)
        Gets the retention strategy descriptor by name. Primarily used for making them web-visible.
      • getComputer

        @Deprecated
        public ComputerSet getComputer()
        Deprecated.
        UI method. Not meant to be used programmatically.
      • getDescriptor

        public Descriptor getDescriptor​(String id)
        Exposes Descriptor by its name to URL. After doing all the getXXX(shortClassName) methods, I finally realized that this just doesn't scale.
        Parameters:
        id - Either Descriptor.getId() (recommended) or the short name of a Describable subtype (for compatibility)
        Throws:
        IllegalArgumentException - if a short name was passed which matches multiple IDs (fail fast)
      • getDescriptorByType

        public <T extends Descriptor> T getDescriptorByType​(Class<T> type)
        Gets the Descriptor instance in the current Jenkins by its type.
      • updateNewComputer

        protected void updateNewComputer​(Node n)
      • updateComputerList

        protected void updateComputerList()
      • getPlugin

        @CheckForNull
        public Plugin getPlugin​(String shortName)
        Gets the plugin object from its short name. This allows URL hudson/plugin/ID to be served by the views of the plugin class.
        Parameters:
        shortName - Short name of the plugin
        Returns:
        The plugin singleton or null if for some reason the plugin is not loaded. The fact the plugin is loaded does not mean it is enabled and fully initialized for the current Jenkins session. Use Plugin.getWrapper() and then PluginWrapper.isActive() to check it.
      • getPlugin

        @CheckForNull
        public <P extends Plugin> P getPlugin​(Class<P> clazz)
        Gets the plugin object from its class.

        This allows easy storage of plugin information in the plugin singleton without every plugin reimplementing the singleton pattern.

        Type Parameters:
        P - Class of the plugin
        Parameters:
        clazz - The plugin class (beware class-loader fun, this will probably only work from within the jpi that defines the plugin class, it may or may not work in other cases)
        Returns:
        The plugin singleton or null if for some reason the plugin is not loaded. The fact the plugin is loaded does not mean it is enabled and fully initialized for the current Jenkins session. Use Plugin.getWrapper() and then PluginWrapper.isActive() to check it.
      • getPlugins

        public <P extends PluginList<P> getPlugins​(Class<P> clazz)
        Gets the plugin objects from their super-class.
        Parameters:
        clazz - The plugin class (beware class-loader fun)
        Returns:
        The plugin instances.
      • getMarkupFormatter

        @NonNull
        public MarkupFormatter getMarkupFormatter()
        Gets the markup formatter used in the system.
        Returns:
        never null.
        Since:
        1.391
      • setMarkupFormatter

        public void setMarkupFormatter​(MarkupFormatter f)
        Sets the markup formatter used in the system globally.
        Since:
        1.391
      • getActions

        public List<Action> getActions()
        Returns the transient Actions associated with the top page.

        Adding Action is primarily useful for plugins to contribute an item to the navigation bar of the top page. See existing Action implementation for it affects the GUI.

        To register an Action, implement RootAction extension point, or write code like Jenkins.get().getActions().add(...).

        Returns:
        Live list where the changes can be made. Can be empty but never null.
        Since:
        1.172
      • getItemMap

        public Map<String,​TopLevelItem> getItemMap()
        Returns the read-only view of all the TopLevelItems keyed by their names.

        This method is efficient, as it doesn't involve any copying.

        Since:
        1.296
      • getItems

        public <T> List<T> getItems​(Class<T> type)
        Gets just the immediate children of Jenkins but of the given type.
      • getViewActions

        public List<Action> getViewActions()
        Description copied from interface: ViewGroup
        Returns actions that should be displayed in views.

        In this interface, the return value is used read-only. This doesn't prevent subtypes from returning modifiable actions, however.

        Specified by:
        getViewActions in interface ViewGroup
        Returns:
        may be empty but never null; getActions() by default
        See Also:
        Actionable.getActions()
      • getView

        @CheckForNull
        public View getView​(@CheckForNull
                            String name)
        Gets a view by the specified name. The method iterates through ViewGroups if required.
        Specified by:
        getView in interface ViewGroup
        Parameters:
        name - Name of the view
        Returns:
        View instance or null if it is missing
      • getViews

        @Exported
        public Collection<View> getViews()
        Gets the read-only list of all Views.
        Specified by:
        getViews in interface ViewGroup
        Returns:
        can be empty but never null.
      • setViews

        public void setViews​(Collection<View> views)
                      throws IOException
        Completely replaces views.

        This operation is NOT provided as an atomic operation, but rather the sole purpose of this is to define a setter for this to help introspecting code, such as system-config-dsl plugin

        Throws:
        IOException
      • canDelete

        public boolean canDelete​(View view)
        Description copied from interface: ViewGroup
        Determine whether a view may be deleted.
        Specified by:
        canDelete in interface ViewGroup
      • onViewRenamed

        public void onViewRenamed​(View view,
                                  String oldName,
                                  String newName)
        Description copied from interface: ViewGroup
        View calls this method when it's renamed. This method is intended to work as a notification to the ViewGroup (so that it can adjust its internal data structure, for example.)

        It is the caller's responsibility to ensure that the new name is a legal view name.

        Specified by:
        onViewRenamed in interface ViewGroup
      • getPrimaryView

        @Exported
        public View getPrimaryView()
        Returns the primary View that renders the top-page of Jenkins.
        Specified by:
        getPrimaryView in interface ViewGroup
        Returns:
        by default, null
      • setPrimaryView

        public void setPrimaryView​(@NonNull
                                   View v)
      • getViewsTabBar

        public ViewsTabBar getViewsTabBar()
        Description copied from interface: ViewGroup
        Gets the TabBar for the views. TabBar for views can be provided by extension. Only one TabBar can be active at a given time (Selectable by user in the global Configuration page). Default TabBar is provided by Hudson Platform.
        Specified by:
        getViewsTabBar in interface ViewGroup
      • setViewsTabBar

        public void setViewsTabBar​(ViewsTabBar viewsTabBar)
      • getItemGroup

        public Jenkins getItemGroup()
        Description copied from interface: ViewGroup
        Returns the ItemGroup from which the views in this group should render items.

        Generally speaking, Views render a subset of TopLevelItems that belong to this item group.

        Specified by:
        getItemGroup in interface ViewGroup
        Returns:
        Never null. Sometimes this is ModifiableItemGroup (if the container allows arbitrary addition). By default, get().
      • setMyViewsTabBar

        public void setMyViewsTabBar​(MyViewsTabBar myViewsTabBar)
      • isUpgradedFromBefore

        public boolean isUpgradedFromBefore​(VersionNumber v)
        Returns true if the current running Jenkins is upgraded from a version earlier than the specified version.

        This method continues to return true until the system configuration is saved, at which point version will be overwritten and Jenkins forgets the upgrade history.

        To handle SNAPSHOTS correctly, pass in "1.N.*" to test if it's upgrading from the version equal or younger than N. So say if you implement a feature in 1.301 and you want to check if the installation upgraded from pre-1.301, pass in "1.300.*"

        Since:
        1.301
      • getComputers

        public Computer[] getComputers()
        Gets the read-only list of all Computers.
      • getLabel

        @CheckForNull
        public Label getLabel​(String expr)
        Gets the label that exists on this system by the name.
        Returns:
        null if name is null.
        See Also:
        (String)
      • getLabelAtom

        @Nullable
        public LabelAtom getLabelAtom​(@CheckForNull
                                      String name)
        Returns the label atom of the given name.
        Returns:
        non-null iff name is non-null
      • getLabels

        public Set<Label> getLabels()
        Gets all the active labels in the current system.
      • getJDKs

        public List<JDK> getJDKs()
      • setJDKs

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public void setJDKs​(Collection<? extends JDK> jdks)
        Replaces all JDK installations with those from the given collection. Use JDK.DescriptorImpl.setInstallations(JDK...) to set JDK installations from external code.
      • getJDK

        public JDK getJDK​(String name)
        Gets the JDK installation of the given name, or returns null.
      • getNode

        @CheckForNull
        public Node getNode​(String name)
        Gets the agent node of the give name, hooked under this Jenkins.
      • getNodes

        @NonNull
        public List<Node> getNodes()
        Returns all Nodes in the system, excluding Jenkins instance itself which represents the built-in node (in other words, this only returns agents).
        Specified by:
        getNodes in class AbstractCIBase
      • getNodesObject

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public Nodes getNodesObject()
        Get the Nodes object that handles maintaining individual Nodes.
        Returns:
        The Nodes object.
      • addNode

        public void addNode​(Node n)
                     throws IOException
        Adds one more Node to Jenkins. If a node of the same name already exists then that node will be replaced.
        Throws:
        IOException
      • updateNode

        public boolean updateNode​(Node n)
                           throws IOException
        Saves an existing Node on disk, called by Node.save(). This method is preferred in those cases where you need to determine atomically that the node being saved is actually in the list of nodes.
        Parameters:
        n - the node to be updated.
        Returns:
        true, if the node was updated. false, if the node was not in the list of nodes.
        Throws:
        IOException - if the node could not be persisted.
        Since:
        1.634
        See Also:
        Nodes.updateNode(hudson.model.Node)
      • getActiveAdministrativeMonitors

        public List<AdministrativeMonitor> getActiveAdministrativeMonitors()
        Returns the enabled and activated administrative monitors accessible to the current user.
        Since:
        2.64
      • getDescriptor

        public NodeDescriptor getDescriptor()
        Description copied from interface: Describable
        Gets the descriptor for this instance.

        Descriptor is a singleton for every concrete Describable implementation, so if a.getClass() == b.getClass() then by default a.getDescriptor() == b.getDescriptor() as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)

        Specified by:
        getDescriptor in interface Describable<Node>
        Specified by:
        getDescriptor in class Node
      • getQuietPeriod

        public int getQuietPeriod()
        Gets the system default quiet period.
      • setQuietPeriod

        public void setQuietPeriod​(Integer quietPeriod)
                            throws IOException
        Sets the global quiet period.
        Parameters:
        quietPeriod - null to the default value.
        Throws:
        IOException
      • getScmCheckoutRetryCount

        public int getScmCheckoutRetryCount()
        Gets the global SCM check out retry count.
      • setScmCheckoutRetryCount

        public void setScmCheckoutRetryCount​(int scmCheckoutRetryCount)
                                      throws IOException
        Throws:
        IOException
      • getSearchUrl

        public String getSearchUrl()
        Description copied from interface: SearchItem
        Returns the URL of this item relative to the parent SearchItem.
        Specified by:
        getSearchUrl in interface SearchItem
        Overrides:
        getSearchUrl in class Node
        Returns:
        URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
      • getRootUrl

        @Nullable
        public String getRootUrl()
                          throws IllegalStateException
        Gets the absolute URL of Jenkins, such as http://localhost/jenkins/.

        This method first tries to use the manually configured value, then fall back to getRootUrlFromRequest(). It is done in this order so that it can work correctly even in the face of a reverse proxy.

        Returns:
        null if this parameter is not configured by the user and the calling thread is not in an HTTP request; otherwise the returned URL will always have the trailing /
        Throws:
        IllegalStateException - JenkinsLocationConfiguration cannot be retrieved. Jenkins instance may be not ready, or there is an extension loading glitch.
        Since:
        1.66
        See Also:
        Hyperlinks in HTML
      • getConfiguredRootUrl

        @Exported(name="url")
        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        @CheckForNull
        public String getConfiguredRootUrl()
      • isRootUrlSecure

        public boolean isRootUrlSecure()
        Is Jenkins running in HTTPS? Note that we can't really trust ServletRequest.isSecure() because HTTPS might be terminated in the reverse proxy.
      • getRootUrlFromRequest

        @NonNull
        public String getRootUrlFromRequest()
        Gets the absolute URL of Jenkins top page, such as http://localhost/jenkins/.

        Unlike getRootUrl(), which uses the manually configured value, this one uses the current request to reconstruct the URL. The benefit is that this is immune to the configuration mistake (users often fail to set the root URL correctly, especially when a migration is involved), but the downside is that unless you are processing a request, this method doesn't work.

        Please note that this will not work in all cases if Jenkins is running behind a reverse proxy which has not been fully configured. Specifically the Host and X-Forwarded-Proto headers must be set. Reverse proxy - Apache shows some examples of configuration.

        Since:
        1.263
      • getRootDir

        public File getRootDir()
        Description copied from interface: PersistenceRoot
        Gets the root directory on the file system that this Item can use freely for storing the configuration data.

        This parameter is given by the ItemGroup when Item is loaded from memory.

        Specified by:
        getRootDir in interface PersistenceRoot
      • getWorkspaceFor

        public FilePath getWorkspaceFor​(TopLevelItem item)
        Description copied from class: Node
        Returns a "workspace" directory for the given TopLevelItem.

        Workspace directory is usually used for keeping out the checked out source code, but it can be used for anything.

        Specified by:
        getWorkspaceFor in class Node
        Returns:
        null if this node is not connected hence the path is not available
      • getBuildDirFor

        public File getBuildDirFor​(Job job)
      • isDefaultBuildDir

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public boolean isDefaultBuildDir()
        If the configured buildsDir has it's default value or has been changed.
        Returns:
        true if default value.
      • expandVariablesForDirectory

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static String expandVariablesForDirectory​(String base,
                                                         String itemFullName,
                                                         String itemRootDir)
      • getRawWorkspaceDir

        public String getRawWorkspaceDir()
      • getRawBuildsDir

        public String getRawBuildsDir()
      • setRawBuildsDir

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public void setRawBuildsDir​(String buildsDir)
      • getRootPath

        @NonNull
        public FilePath getRootPath()
        Description copied from class: Node
        Gets the root directory of this node.

        Hudson always owns a directory on every node. This method returns that.

        Specified by:
        getRootPath in class Node
        Returns:
        null if the node is offline and hence the FilePath object is not available.
      • getClockDifference

        public ClockDifference getClockDifference()
        Description copied from class: Node
        Estimates the clock difference with this agent.
        Overrides:
        getClockDifference in class Node
        Returns:
        always non-null.
      • getClockDifferenceCallable

        public hudson.remoting.Callable<ClockDifference,​IOException> getClockDifferenceCallable()
        Description copied from class: Node
        Returns a Callable that when run on the channel, estimates the clock difference.
        Specified by:
        getClockDifferenceCallable in class Node
        Returns:
        always non-null.
      • setLog

        public void setLog​(LogRecorderManager log)
        Set the LogRecorderManager.
        Parameters:
        log - the LogRecorderManager to set
        Since:
        2.323
      • isUseSecurity

        @Exported
        public boolean isUseSecurity()
        A convenience method to check if there's some security restrictions in place.
      • isUseProjectNamingStrategy

        public boolean isUseProjectNamingStrategy()
      • isUseCrumbs

        @Exported
        public boolean isUseCrumbs()
        If true, all the POST requests to Jenkins would have to have crumb in it to protect Jenkins from CSRF vulnerabilities.
      • getSecurity

        public SecurityMode getSecurity()
        Returns the constant that captures the three basic security modes in Jenkins.
      • getSecurityRealm

        public SecurityRealm getSecurityRealm()
        Returns:
        never null.
      • setSecurityRealm

        public void setSecurityRealm​(@CheckForNull
                                     SecurityRealm securityRealm)
        Sets a security realm.
        Parameters:
        securityRealm - Security realm to set. If null, SecurityRealm.NO_AUTHENTICATION will be set.
      • isDisableRememberMe

        public boolean isDisableRememberMe()
      • setDisableRememberMe

        public void setDisableRememberMe​(boolean disableRememberMe)
      • disableSecurity

        public void disableSecurity()
      • getLifecycle

        public Lifecycle getLifecycle()
      • getInjector

        @CheckForNull
        public com.google.inject.Injector getInjector()
        Gets the dependency injection container that hosts all the extension implementations and other components in Jenkins.
        Since:
        1.433
      • getExtensionList

        public <T> ExtensionList<T> getExtensionList​(Class<T> extensionType)
        Returns ExtensionList that retains the discovered instances for the given extension type.
        Parameters:
        extensionType - The base type that represents the extension point. Normally ExtensionPoint subtype but that's not a hard requirement.
        Returns:
        Can be an empty list but never null.
        See Also:
        ExtensionList.lookup(java.lang.Class<T>)
      • getAuthorizationStrategy

        public AuthorizationStrategy getAuthorizationStrategy()
        Returns:
        never null.
      • getProjectNamingStrategy

        public ProjectNamingStrategy getProjectNamingStrategy()
        The strategy used to check the project names.
        Returns:
        never null
      • isQuietingDown

        @Exported
        public boolean isQuietingDown()
        Returns true if Jenkins is quieting down.

        No further jobs will be executed unless it can be finished while other current pending builds are still in progress.

      • getQuietDownReason

        @Exported
        @CheckForNull
        public String getQuietDownReason()
        Returns quiet down reason if it was indicated.
        Returns:
        Reason if it was indicated. null otherwise
        Since:
        2.267
      • isTerminating

        public boolean isTerminating()
        Returns true if the container initiated the termination of the web application.
      • getInitLevel

        public InitMilestone getInitLevel()
        Gets the initialization milestone that we've already reached.
        Returns:
        InitMilestone.STARTED even if the initialization hasn't been started, so that this method never returns null.
      • getItem

        public TopLevelItem getItem​(String name)
                             throws org.springframework.security.access.AccessDeniedException
        Gets the Item inside this group that has a given name, or null if it does not exist.. Note that the look up is case-insensitive.
        Specified by:
        getItem in interface ItemGroup<TopLevelItem>
        Returns:
        an item whose Item.getName() is name and whose Item.getParent() is this, or null if there is no such item, or there is but the current user lacks both Item.DISCOVER and Item.READ on it
        Throws:
        org.springframework.security.access.AccessDeniedException - if the current user has Item.DISCOVER but not Item.READ on this item
      • getItem

        public Item getItem​(String pathName,
                            ItemGroup context)
        Gets the item by its path name from the given context

        Path Names: If the name starts from '/', like "/foo/bar/zot", then it's interpreted as absolute. Otherwise, the name should be something like "foo/bar" and it's interpreted like relative path name in the file system is, against the given context.

        For compatibility, as a fallback when nothing else matches, a simple path like foo/bar can also be treated with getItemByFullName(java.lang.String, java.lang.Class<T>).

        Parameters:
        context - null is interpreted as Jenkins. Base 'directory' of the interpretation.
        Since:
        1.406
      • getItem

        public final Item getItem​(String pathName,
                                  Item context)
      • getItem

        public final <T extends Item> T getItem​(String pathName,
                                                Item context,
                                                Class<T> type)
      • getItemByFullName

        @CheckForNull
        public <T extends Item> T getItemByFullName​(@NonNull
                                                    String fullName,
                                                    Class<T> type)
                                             throws org.springframework.security.access.AccessDeniedException
        Gets the Item object by its full name. Full names are like path names, where each name of Item is combined by '/'.
        Returns:
        null if either such Item doesn't exist under the given full name, or it exists but it's no an instance of the given type.
        Throws:
        org.springframework.security.access.AccessDeniedException - as per ItemGroup.getItem(java.lang.String)
      • getItemByFullName

        @CheckForNull
        public Item getItemByFullName​(String fullName)
      • getNumExecutors

        public int getNumExecutors()
        Description copied from class: Node
        Returns the number of Executors. This may be different from getExecutors().size() because it takes time to adjust the number of executors.
        Specified by:
        getNumExecutors in class Node
      • getMode

        public Node.Mode getMode()
        Description copied from class: Node
        Returns Node.Mode.EXCLUSIVE if this node is only available for those jobs that exclusively specifies this node as the assigned node.
        Specified by:
        getMode in class Node
      • getLabelString

        public String getLabelString()
        Description copied from class: Node
        Returns the manually configured label for a node. The list of assigned and dynamically determined labels is available via Node.getAssignedLabels() and includes all labels that have been manually configured. Mainly for form binding.
        Specified by:
        getLabelString in class Node
      • getSelfLabel

        @NonNull
        public LabelAtom getSelfLabel()
        Description copied from class: Node
        Gets the special label that represents this node itself.
        Overrides:
        getSelfLabel in class Node
      • createComputer

        @NonNull
        public Computer createComputer()
        Description copied from class: Node
        Creates a new Computer object that acts as the UI peer of this Node. Nobody but updateComputerList() should call this method.
        Specified by:
        createComputer in class Node
        Returns:
        Created instance of the computer. Can be null if the Node implementation does not support it (e.g. Cloud agent).
      • cleanUp

        public void cleanUp()
        Called to shut down the system.
      • getCrumbIssuer

        @CheckForNull
        public CrumbIssuer getCrumbIssuer()
        Gets the CrumbIssuer currently in use.
        Returns:
        null if none is in use.
      • setCrumbIssuer

        public void setCrumbIssuer​(CrumbIssuer issuer)
      • doTestPost

        public void doTestPost​(org.kohsuke.stapler.StaplerRequest req,
                               org.kohsuke.stapler.StaplerResponse rsp)
                        throws IOException,
                               javax.servlet.ServletException
        Throws:
        IOException
        javax.servlet.ServletException
      • doConfigExecutorsSubmit

        @POST
        public void doConfigExecutorsSubmit​(org.kohsuke.stapler.StaplerRequest req,
                                            org.kohsuke.stapler.StaplerResponse rsp)
                                     throws IOException,
                                            javax.servlet.ServletException,
                                            Descriptor.FormException
        Accepts submission from the node configuration page.
        Throws:
        IOException
        javax.servlet.ServletException
        Descriptor.FormException
      • doSubmitDescription

        public void doSubmitDescription​(org.kohsuke.stapler.StaplerRequest req,
                                        org.kohsuke.stapler.StaplerResponse rsp)
                                 throws IOException,
                                        javax.servlet.ServletException
        Accepts the new description.
        Throws:
        IOException
        javax.servlet.ServletException
      • doQuietDown

        public org.kohsuke.stapler.HttpRedirect doQuietDown()
      • doQuietDown

        @Deprecated
        public org.kohsuke.stapler.HttpRedirect doQuietDown​(boolean block,
                                                            int timeout)
        Deprecated.
        since 2.267; use doQuietDown(boolean, int, String) instead.
        Quiet down Jenkins - preparation for a restart Presented for compatibility.
        Parameters:
        block - Block until the system really quiets down and no builds are running
        timeout - If non-zero, only block up to the specified number of milliseconds
      • doQuietDown

        public org.kohsuke.stapler.HttpRedirect doQuietDown​(@QueryParameter
                                                            boolean block,
                                                            @QueryParameter
                                                            int timeout,
                                                            @QueryParameter @CheckForNull
                                                            String reason)
                                                     throws InterruptedException,
                                                            IOException
        Quiet down Jenkins - preparation for a restart
        Parameters:
        block - Block until the system really quiets down and no builds are running
        timeout - If non-zero, only block up to the specified number of milliseconds
        reason - Quiet reason that will be visible to user
        Throws:
        InterruptedException
        IOException
        Since:
        2.267
      • doCancelQuietDown

        public org.kohsuke.stapler.HttpRedirect doCancelQuietDown()
        Cancel previous quiet down Jenkins - preparation for a restart
      • doToggleCollapse

        public org.kohsuke.stapler.HttpResponse doToggleCollapse()
                                                          throws javax.servlet.ServletException,
                                                                 IOException
        Throws:
        javax.servlet.ServletException
        IOException
      • doClassicThreadDump

        public void doClassicThreadDump​(org.kohsuke.stapler.StaplerResponse rsp)
                                 throws IOException,
                                        javax.servlet.ServletException
        Backward compatibility. Redirect to the thread dump.
        Throws:
        IOException
        javax.servlet.ServletException
      • checkGoodName

        public static void checkGoodName​(String name)
                                  throws Failure
        Check if the given name is suitable as a name for job, view, etc.
        Throws:
        Failure - if the given name is not good
      • doSecured

        public void doSecured​(org.kohsuke.stapler.StaplerRequest req,
                              org.kohsuke.stapler.StaplerResponse rsp)
                       throws IOException,
                              javax.servlet.ServletException
        Checks if the user was successfully authenticated.
        Throws:
        IOException
        javax.servlet.ServletException
        See Also:
        BasicAuthenticationFilter
      • doLoginEntry

        public void doLoginEntry​(org.kohsuke.stapler.StaplerRequest req,
                                 org.kohsuke.stapler.StaplerResponse rsp)
                          throws IOException
        Called once the user logs in. Just forward to the top page. Used only by LegacySecurityRealm.
        Throws:
        IOException
      • doLogout

        public void doLogout​(org.kohsuke.stapler.StaplerRequest req,
                             org.kohsuke.stapler.StaplerResponse rsp)
                      throws IOException,
                             javax.servlet.ServletException
        Logs out the user.
        Throws:
        IOException
        javax.servlet.ServletException
      • getJnlpJars

        public Slave.JnlpJar getJnlpJars​(String fileName)
        Serves jar files for inbound agents.
      • doJnlpJars

        public Slave.JnlpJar doJnlpJars​(org.kohsuke.stapler.StaplerRequest req)
      • doReload

        public org.kohsuke.stapler.HttpResponse doReload()
                                                  throws IOException
        Reloads the configuration.
        Throws:
        IOException
      • doDoFingerprintCheck

        public void doDoFingerprintCheck​(org.kohsuke.stapler.StaplerRequest req,
                                         org.kohsuke.stapler.StaplerResponse rsp)
                                  throws IOException,
                                         javax.servlet.ServletException
        Do a finger-print check.
        Throws:
        IOException
        javax.servlet.ServletException
      • doGc

        public void doGc​(org.kohsuke.stapler.StaplerResponse rsp)
                  throws IOException
        For debugging. Expose URL to perform GC.
        Throws:
        IOException
      • doException

        @StaplerDispatchable
        public void doException()
        End point that intentionally throws an exception to test the error behaviour.
        Since:
        1.467
      • doSimulateOutOfMemory

        public void doSimulateOutOfMemory()
                                   throws IOException
        Simulates OutOfMemoryError. Useful to make sure OutOfMemoryHeapDump setting.
        Throws:
        IOException
      • doUserContent

        public DirectoryBrowserSupport doUserContent()
        Binds /userContent/... to $JENKINS_HOME/userContent.
      • doExit

        @CLIMethod(name="shutdown")
        public void doExit​(org.kohsuke.stapler.StaplerRequest req,
                           org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException
        Shutdown the system.
        Throws:
        IOException
        Since:
        1.161
      • doSafeExit

        @CLIMethod(name="safe-shutdown")
        public org.kohsuke.stapler.HttpResponse doSafeExit​(org.kohsuke.stapler.StaplerRequest req)
                                                    throws IOException
        Shutdown the system safely.
        Throws:
        IOException
        Since:
        1.332
      • getAuthentication2

        @NonNull
        public static org.springframework.security.core.Authentication getAuthentication2()
        Gets the Authentication object that represents the user associated with the current request.
        Since:
        2.266
      • doScript

        public void doScript​(org.kohsuke.stapler.StaplerRequest req,
                             org.kohsuke.stapler.StaplerResponse rsp)
                      throws IOException,
                             javax.servlet.ServletException
        For system diagnostics. Run arbitrary Groovy script.
        Throws:
        IOException
        javax.servlet.ServletException
      • doScriptText

        public void doScriptText​(org.kohsuke.stapler.StaplerRequest req,
                                 org.kohsuke.stapler.StaplerResponse rsp)
                          throws IOException,
                                 javax.servlet.ServletException
        Run arbitrary Groovy script and return result as plain text.
        Throws:
        IOException
        javax.servlet.ServletException
      • _doScript

        public static void _doScript​(org.kohsuke.stapler.StaplerRequest req,
                                     org.kohsuke.stapler.StaplerResponse rsp,
                                     javax.servlet.RequestDispatcher view,
                                     hudson.remoting.VirtualChannel channel,
                                     ACL acl)
                              throws IOException,
                                     javax.servlet.ServletException
        Throws:
        IOException
        javax.servlet.ServletException
        Since:
        1.509.1
      • doEval

        public void doEval​(org.kohsuke.stapler.StaplerRequest req,
                           org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException,
                           javax.servlet.ServletException
        Evaluates the Jelly script submitted by the client. This is useful for system administration as well as unit testing.
        Throws:
        IOException
        javax.servlet.ServletException
      • doSignup

        public void doSignup​(org.kohsuke.stapler.StaplerRequest req,
                             org.kohsuke.stapler.StaplerResponse rsp)
                      throws IOException,
                             javax.servlet.ServletException
        Sign up for the user account.
        Throws:
        IOException
        javax.servlet.ServletException
      • doIconSize

        public void doIconSize​(org.kohsuke.stapler.StaplerRequest req,
                               org.kohsuke.stapler.StaplerResponse rsp)
                        throws IOException,
                               javax.servlet.ServletException
        Changes the icon size by changing the cookie
        Throws:
        IOException
        javax.servlet.ServletException
      • doFingerprintCleanup

        public void doFingerprintCleanup​(org.kohsuke.stapler.StaplerResponse rsp)
                                  throws IOException
        Throws:
        IOException
      • doWorkspaceCleanup

        public void doWorkspaceCleanup​(org.kohsuke.stapler.StaplerResponse rsp)
                                throws IOException
        Throws:
        IOException
      • doDefaultJDKCheck

        public FormValidation doDefaultJDKCheck​(org.kohsuke.stapler.StaplerRequest request,
                                                @QueryParameter
                                                String value)
        If the user chose the default JDK, make sure we got 'java' in PATH.
      • doCheckViewName

        public FormValidation doCheckViewName​(@QueryParameter
                                              String value)
        Checks if a top-level view with the given name exists and make sure that the name is good as a view name.
      • doViewExistsCheck

        @Deprecated
        public FormValidation doViewExistsCheck​(@QueryParameter
                                                String value)
        Deprecated.
        1.512
        Checks if a top-level view with the given name exists.
      • doResources

        public void doResources​(org.kohsuke.stapler.StaplerRequest req,
                                org.kohsuke.stapler.StaplerResponse rsp)
                         throws IOException,
                                javax.servlet.ServletException
        Serves static resources placed along with Jelly view files.

        This method can serve a lot of files, so care needs to be taken to make this method secure. It's not clear to me what's the best strategy here, though the current implementation is based on file extensions.

        Throws:
        IOException
        javax.servlet.ServletException
      • rebuildDependencyGraph

        public void rebuildDependencyGraph()
        Rebuilds the dependency map.
      • rebuildDependencyGraphAsync

        public Future<DependencyGraph> rebuildDependencyGraphAsync()
        Rebuilds the dependency map asynchronously.

        This would keep the UI thread more responsive and helps avoid the deadlocks, as dependency graph recomputation tends to touch a lot of other things.

        Since:
        1.522
      • getSetupWizard

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public SetupWizard getSetupWizard()
        If set, a currently active setup wizard - e.g. installation
        Since:
        2.0
      • getMe

        public User getMe()
        Exposes the current user to /me URL.
      • getWidgets

        @StaplerDispatchable
        public List<Widget> getWidgets()
        Gets the Widgets registered on this object.

        Plugins who wish to contribute boxes on the side panel can add widgets by getWidgets().add(new MyWidget()) from Plugin.start().

      • getTarget

        public Object getTarget()
        Specified by:
        getTarget in interface org.kohsuke.stapler.StaplerProxy
      • isSubjectToMandatoryReadPermissionCheck

        public boolean isSubjectToMandatoryReadPermissionCheck​(String restOfPath)
        Test a path to see if it is subject to mandatory read permission checks by container-managed security
        Parameters:
        restOfPath - the URI, excluding the Jenkins root URI and query string
        Returns:
        true if the path is subject to mandatory read permission checks
        Since:
        2.37
      • getUnprotectedRootActions

        public Collection<String> getUnprotectedRootActions()
        Gets a list of unprotected root actions. These URL prefixes should be exempted from access control checks by container-managed security. Ideally would be synchronized with getTarget().
        Returns:
        a list of URL names
        Since:
        1.495
      • getStaplerFallback

        public View getStaplerFallback()
        Fallback to the primary view.
        Specified by:
        getStaplerFallback in interface org.kohsuke.stapler.StaplerFallback
      • doCheckDisplayName

        public FormValidation doCheckDisplayName​(@QueryParameter
                                                 String displayName,
                                                 @QueryParameter
                                                 String jobName)
        Checks to see if the candidate displayName collides with any existing display names or project names
        Parameters:
        displayName - The display name to test
        jobName - The name of the job the user is configuring
      • lookup

        @CheckForNull
        public static <T> T lookup​(Class<T> type)
        Shortcut for Jenkins.getInstanceOrNull()?.lookup.get(type)
      • getVersion

        @CheckForNull
        public static VersionNumber getVersion()
        Parses VERSION into VersionNumber, or null if it's not parseable as a version number (such as when Jenkins is run with mvn jetty:run)
      • shouldShowStackTrace

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public boolean shouldShowStackTrace()