@ExportedBean public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLevelItemGroup, org.kohsuke.stapler.StaplerProxy, org.kohsuke.stapler.StaplerFallback, ModifiableViewGroup, AccessControlled, DescriptorByNameOwner, ModelObjectWithContextMenu, ModelObjectWithChildren, OnMaster
Modifier and Type | Class and Description |
---|---|
static class |
Jenkins.CloudList |
static class |
Jenkins.DescriptorImpl |
static class |
Jenkins.EnforceSlaveAgentPortAdministrativeMonitor |
static interface |
Jenkins.JenkinsHolder
Hook for a test harness to intercept Jenkins.get()
Do not use in the production code as the signature may change.
|
static class |
Jenkins.MasterComputer |
static class |
Jenkins.MasterRestartNotifyier |
Node.InternalComputerListener, Node.Mode
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem
ExtensionPoint.LegacyInstancesAreScopedToHudson
Modifier and Type | Field and Description |
---|---|
static Permission |
ADMINISTER |
List<AdministrativeMonitor> |
administrativeMonitors
AdministrativeMonitor s installed on this system. |
static Set<String> |
ALLOWED_RESOURCE_EXTENSIONS
Extension list that
doResources(StaplerRequest, StaplerResponse) can serve. |
static Authentication |
ANONYMOUS
Deprecated.
use
ANONYMOUS2 |
static org.springframework.security.core.Authentication |
ANONYMOUS2
Authentication object that represents the anonymous user. |
static boolean |
AUTOMATIC_SLAVE_LAUNCH
Automatically try to launch an agent when Jenkins is initialized or a new agent computer is created.
|
static String |
CHANGELOG_URL |
Hudson.CloudList |
clouds
Active
Cloud s. |
protected Map<Node,Computer> |
computers
Computer s in this Jenkins system. |
static boolean |
CONCURRENT_BUILD
Deprecated.
as of 1.464
This flag will have no effect.
|
static boolean |
FLYWEIGHT_SUPPORT
Deprecated.
No longer used.
|
static boolean |
KILL_AFTER_LOAD |
static List<LogRecord> |
logRecords
Live view of recent
LogRecord s produced by Jenkins. |
Lookup |
lookup
Stores various objects scoped to
Jenkins . |
static Permission |
MANAGE
This permission grants access to parts of the Jenkins system configuration.
|
static Permission[] |
MANAGE_AND_SYSTEM_READ |
OverallLoadStatistics |
overallLoad
Load statistics of the entire system.
|
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. |
static boolean |
PARALLEL_LOAD |
static PermissionGroup |
PERMISSIONS |
PluginManager |
pluginManager
Loaded plugins.
|
ProxyConfiguration |
proxy
HTTP proxy configuration.
|
static Permission |
READ |
static String |
RESOURCE_PATH
Prefix to static resources like images and javascripts in the war file.
|
File |
root
Root directory of the system.
|
static Permission |
RUN_SCRIPTS
Deprecated.
in Jenkins 2.222 use
ADMINISTER instead |
javax.servlet.ServletContext |
servletContext |
static String |
SESSION_HASH
Unique random token that identifies the current session.
|
protected NodeList |
slaves
Deprecated.
in favour of
Nodes |
static Permission |
SYSTEM_READ
Allows read-only access to large parts of the system configuration.
|
TcpSlaveAgentListener |
tcpSlaveAgentListener |
static String |
UNCOMPUTED_VERSION
The version number before it is "computed" (by a call to computeVersion()).
|
LoadStatistics |
unlabeledLoad
Load statistics of the free roaming jobs and agents.
|
NodeProvisioner |
unlabeledNodeProvisioner
NodeProvisioner that reacts to unlabeledLoad . |
static String |
VERSION
Version number of this Jenkins.
|
static String |
VERSION_HASH
Hash of
VERSION . |
static String |
VIEW_RESOURCE_PATH
Prefix to resources alongside view scripts.
|
static com.thoughtworks.xstream.XStream |
XSTREAM
Thread-safe reusable
XStream . |
static XStream2 |
XSTREAM2
|
LOG_STARTUP_PERFORMANCE
holdOffLaunchUntilSave, SKIP_BUILD_CHECK_ON_FLYWEIGHTS
Modifier | Constructor and Description |
---|---|
protected |
Jenkins(File root,
javax.servlet.ServletContext context) |
protected |
Jenkins(File root,
javax.servlet.ServletContext context,
PluginManager pluginManager) |
Modifier and Type | Method and Description |
---|---|
static void |
_doScript(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp,
javax.servlet.RequestDispatcher view,
hudson.remoting.VirtualChannel channel,
ACL acl) |
Fingerprint |
_getFingerprint(String md5sum)
Gets a
Fingerprint object if it exists. |
<I extends TopLevelItem> |
add(I item,
String name)
Adds an item to this group.
|
void |
addNode(Node n)
Adds one more
Node to Jenkins. |
void |
addView(View v)
|
boolean |
canAdd(TopLevelItem item)
Returns true if a particular item may be added to this group.
|
boolean |
canDelete(View view)
Determine whether a view may be deleted.
|
static void |
checkGoodName(String name)
Check if the given name is suitable as a name
for job, view, etc.
|
void |
cleanUp()
Called to shut down the system.
|
<T extends AbstractProject<?,?>> |
copy(T src,
String name) |
<T extends TopLevelItem> |
copy(T src,
String name)
Copies a job.
|
Computer |
createComputer()
|
Launcher |
createLauncher(TaskListener listener)
Returns a
Launcher for executing programs on this node. |
FilePath |
createPath(String absolutePath)
Gets the
FilePath on this node. |
<T extends TopLevelItem> |
createProject(Class<T> type,
String name)
Creates a new job.
|
TopLevelItem |
createProject(TopLevelItemDescriptor type,
String name) |
TopLevelItem |
createProject(TopLevelItemDescriptor type,
String name,
boolean notify)
Creates a new job.
|
TopLevelItem |
createProjectFromXML(String name,
InputStream xml)
Creates a new job from its configuration XML.
|
void |
deleteView(View view)
Deletes a view in this group.
|
void |
disableSecurity() |
org.kohsuke.stapler.HttpRedirect |
doCancelQuietDown()
Cancel previous quiet down Jenkins - preparation for a restart
|
FormValidation |
doCheckDisplayName(String displayName,
String jobName)
Checks to see if the candidate displayName collides with any
existing display names or project names
|
FormValidation |
doCheckURIEncoding(org.kohsuke.stapler.StaplerRequest request)
Deprecated.
|
FormValidation |
doCheckViewName(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.
|
ModelObjectWithContextMenu.ContextMenu |
doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request,
org.kohsuke.stapler.StaplerResponse response)
Generates the context menu to list up all the children.
|
void |
doClassicThreadDump(org.kohsuke.stapler.StaplerResponse rsp)
Backward compatibility.
|
void |
doConfigExecutorsSubmit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts submission from the node configuration page.
|
void |
doConfigSubmit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts submission from the configuration page.
|
ModelObjectWithContextMenu.ContextMenu |
doContextMenu(org.kohsuke.stapler.StaplerRequest request,
org.kohsuke.stapler.StaplerResponse response)
Generates the context menu.
|
TopLevelItem |
doCreateItem(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
The request format follows that of
<n:form xmlns:n="/lib/form"> . |
void |
doCreateView(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp) |
FormValidation |
doDefaultJDKCheck(org.kohsuke.stapler.StaplerRequest request,
String value)
If the user chose the default JDK, make sure we got 'java' in PATH.
|
void |
doDoFingerprintCheck(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Do a finger-print check.
|
void |
doEval(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Evaluates the Jelly script submitted by the client.
|
void |
doException()
End point that intentionally throws an exception to test the error behaviour.
|
void |
doExit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Shutdown the system.
|
void |
doFingerprintCleanup(org.kohsuke.stapler.StaplerResponse rsp) |
void |
doGc(org.kohsuke.stapler.StaplerResponse rsp)
For debugging.
|
void |
doIconSize(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Changes the icon size by changing the cookie
|
Slave.JnlpJar |
doJnlpJars(org.kohsuke.stapler.StaplerRequest req) |
void |
doLoginEntry(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Called once the user logs in.
|
void |
doLogout(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Logs out the user.
|
org.kohsuke.stapler.HttpRedirect |
doQuietDown() |
org.kohsuke.stapler.HttpRedirect |
doQuietDown(boolean block,
int timeout)
Deprecated.
since TODO; use
doQuietDown(boolean, int, String) instead. |
org.kohsuke.stapler.HttpRedirect |
doQuietDown(boolean block,
int timeout,
String reason)
Quiet down Jenkins - preparation for a restart
|
org.kohsuke.stapler.HttpResponse |
doReload()
Reloads the configuration.
|
void |
doResources(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Serves static resources placed along with Jelly view files.
|
void |
doRestart(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Perform a restart of Jenkins, if we can.
|
org.kohsuke.stapler.HttpResponse |
doSafeExit(org.kohsuke.stapler.StaplerRequest req)
Shutdown the system safely.
|
org.kohsuke.stapler.HttpResponse |
doSafeRestart(org.kohsuke.stapler.StaplerRequest req)
Queues up a restart of Jenkins for when there are no builds running, if we can.
|
void |
doScript(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
For system diagnostics.
|
void |
doScriptText(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Run arbitrary Groovy script and return result as plain text.
|
void |
doSecured(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Checks if the user was successfully authenticated.
|
void |
doSignup(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Sign up for the user account.
|
void |
doSimulateOutOfMemory()
Simulates OutOfMemoryError.
|
void |
doSubmitDescription(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts the new description.
|
void |
doTestPost(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp) |
org.kohsuke.stapler.HttpResponse |
doToggleCollapse() |
DirectoryBrowserSupport |
doUserContent()
Binds /userContent/...
|
FormValidation |
doViewExistsCheck(String value)
Deprecated.
1.512
|
void |
doWorkspaceCleanup(org.kohsuke.stapler.StaplerResponse rsp) |
static String |
expandVariablesForDirectory(String base,
String itemFullName,
String itemRootDir) |
static Jenkins |
get()
Gets the
Jenkins singleton. |
ACL |
getACL()
Returns the root
ACL . |
List<Action> |
getActions()
Returns the transient
Action s associated with the top page. |
List<AdministrativeMonitor> |
getActiveAdministrativeMonitors()
Returns the enabled and activated administrative monitors accessible to the current user.
|
static Jenkins |
getActiveInstance()
Deprecated.
This is a verbose historical alias for
get() . |
org.kohsuke.stapler.framework.adjunct.AdjunctManager |
getAdjuncts(String dummy)
Makes
AdjunctManager URL-bound. |
AdministrativeMonitor |
getAdministrativeMonitor(String id)
Binds
AdministrativeMonitor s to URL. |
Set<String> |
getAgentProtocols()
Returns the enabled agent protocols.
|
Map<String,Map<String,String>> |
getAllThreadDumps()
Obtains the thread dump of all agents (including the master.)
|
Api |
getApi() |
View.AsynchPeople |
getAsynchPeople() |
static Authentication |
getAuthentication()
Deprecated.
|
static org.springframework.security.core.Authentication |
getAuthentication2()
Gets the
Authentication object that represents the user
associated with the current request. |
AuthorizationStrategy |
getAuthorizationStrategy() |
File |
getBuildDirFor(Job job) |
Descriptor<Builder> |
getBuilder(String shortClassName)
Gets the builder descriptor by name.
|
Descriptor<BuildWrapper> |
getBuildWrapper(String shortClassName)
Gets the build wrapper descriptor by name.
|
Map<ManagementLink.Category,List<ManagementLink>> |
getCategorizedManagementLinks() |
ClockDifference |
getClockDifference()
Estimates the clock difference with this agent.
|
hudson.remoting.Callable<ClockDifference,IOException> |
getClockDifferenceCallable()
Returns a
Callable that when run on the channel, estimates the clock difference. |
Cloud |
getCloud(String name)
|
ComputerSet |
getComputer()
Deprecated.
UI method. Not meant to be used programmatically.
|
Computer |
getComputer(String name) |
protected Map<Node,Computer> |
getComputerMap() |
Computer[] |
getComputers()
Gets the read-only list of all
Computer s. |
String |
getConfiguredRootUrl()
Exported alias for
JenkinsLocationConfiguration.getUrl() . |
CrumbIssuer |
getCrumbIssuer()
Gets the
CrumbIssuer currently in use. |
DependencyGraph |
getDependencyGraph() |
String |
getDescription() |
NodeDescriptor |
getDescriptor()
Gets the descriptor for this instance.
|
Descriptor |
getDescriptor(Class<? extends Describable> type)
Gets the
Descriptor that corresponds to the given Describable type. |
Descriptor |
getDescriptor(String id)
Exposes
Descriptor by its name to URL. |
Descriptor |
getDescriptorByName(String id)
Alias for
getDescriptor(String) . |
<T extends Descriptor> |
getDescriptorByType(Class<T> type)
Gets the
Descriptor instance in the current Jenkins by its type. |
<T extends Describable<T>,D extends Descriptor<T>> |
getDescriptorList(Class<T> type)
Returns
ExtensionList that retains the discovered Descriptor instances for the given
kind of Describable . |
Descriptor |
getDescriptorOrDie(Class<? extends Describable> type)
Works just like
getDescriptor(Class) but don't take no for an answer. |
String |
getDisplayName() |
Object |
getDynamic(String token) |
<T> ExtensionList<T> |
getExtensionList(Class<T> extensionType)
Returns
ExtensionList that retains the discovered instances for the given extension type. |
ExtensionList |
getExtensionList(String extensionType)
Used to bind
ExtensionList s to URLs. |
FederatedLoginService |
getFederatedLoginService(String name) |
List<FederatedLoginService> |
getFederatedLoginServices() |
Object |
getFingerprint(String md5sum) |
FingerprintMap |
getFingerprintMap() |
String |
getFullDisplayName() |
String |
getFullName()
Gets the full name of this
ItemGroup . |
DescribableList<NodeProperty<?>,NodePropertyDescriptor> |
getGlobalNodeProperties() |
RemotingDiagnostics.HeapDump |
getHeapDump()
Obtains the heap dump.
|
InitMilestone |
getInitLevel()
Gets the initialization milestone that we've already reached.
|
com.google.inject.Injector |
getInjector()
Gets the dependency injection container that hosts all the extension implementations and other
components in Jenkins.
|
InstallState |
getInstallState()
Get the Jenkins
install state . |
static Jenkins |
getInstance()
Deprecated.
This is a historical alias for
getInstanceOrNull() but with ambiguous nullability. Use get() in typical cases. |
static Jenkins |
getInstanceOrNull()
Gets the
Jenkins singleton. |
TopLevelItem |
getItem(String name)
Gets the
Item inside this group that has a given name, or null if it does not exist. |
Item |
getItem(String pathName,
Item context) |
<T extends Item> |
getItem(String pathName,
Item context,
Class<T> type) |
Item |
getItem(String pathName,
ItemGroup context)
Gets the item by its path name from the given context
|
<T extends Item> |
getItem(String pathName,
ItemGroup context,
Class<T> type) |
Item |
getItemByFullName(String fullName) |
<T extends Item> |
getItemByFullName(String fullName,
Class<T> type)
Gets the
Item object by its full name. |
Jenkins |
getItemGroup()
Returns the
ItemGroup from which the views in this group should render items. |
Map<String,TopLevelItem> |
getItemMap()
Returns the read-only view of all the
TopLevelItem s keyed by their names. |
List<TopLevelItem> |
getItems()
Gets just the immediate children of
Jenkins . |
<T> List<T> |
getItems(Class<T> type)
Gets just the immediate children of
Jenkins but of the given type. |
List<TopLevelItem> |
getItems(Predicate<TopLevelItem> pred)
Gets just the immediate children of
Jenkins based on supplied predicate. |
JDK |
getJDK(String name)
Gets the JDK installation of the given name, or returns null.
|
List<JDK> |
getJDKs() |
Slave.JnlpJar |
getJnlpJars(String fileName)
Serves jar files for inbound agents.
|
Collection<String> |
getJobNames()
Gets the names of all the
Job s. |
JobPropertyDescriptor |
getJobProperty(String shortClassName)
Gets the
JobPropertyDescriptor by name. |
Label |
getLabel(String expr)
Gets the label that exists on this system by the name.
|
LabelAtom |
getLabelAtom(String name)
Returns the label atom of the given name.
|
Set<LabelAtom> |
getLabelAtoms() |
Set<Label> |
getLabels()
Gets all the active labels in the current system.
|
String |
getLabelString()
Returns the manually configured label for a node.
|
String |
getLegacyInstanceId()
Returns the unique identifier of this Jenkins that has been historically used to identify
this Jenkins to the outside world.
|
Lifecycle |
getLifecycle() |
LogRecorderManager |
getLog()
For binding
LogRecorderManager to "/log". |
List<ManagementLink> |
getManagementLinks() |
MarkupFormatter |
getMarkupFormatter()
Gets the markup formatter used in the system.
|
User |
getMe()
Exposes the current user to
/me URL. |
Node.Mode |
getMode()
Returns
Node.Mode.EXCLUSIVE if this node is only available
for those jobs that exclusively specifies this node
as the assigned node. |
MyViewsTabBar |
getMyViewsTabBar() |
Node |
getNode(String name)
Gets the agent node of the give name, hooked under this Jenkins.
|
String |
getNodeDescription()
Human-readable description of this node.
|
DescribableList<NodeProperty<?>,NodePropertyDescriptor> |
getNodeProperties()
Gets the
NodeProperty instances configured for this Node . |
List<Node> |
getNodes()
|
Nodes |
getNodesObject()
|
int |
getNumExecutors()
Returns the number of
Executor s. |
View.People |
getPeople() |
<P extends Plugin> |
getPlugin(Class<P> clazz)
Gets the plugin object from its class.
|
Plugin |
getPlugin(String shortName)
Gets the plugin object from its short name.
|
PluginManager |
getPluginManager() |
<P extends Plugin> |
getPlugins(Class<P> clazz)
Gets the plugin objects from their super-class.
|
View |
getPrimaryView()
Returns the primary
View that renders the top-page of Jenkins. |
ProjectNamingStrategy |
getProjectNamingStrategy()
The strategy used to check the project names.
|
List<Project> |
getProjects()
Deprecated.
This method will ignore Maven and matrix projects, as well as projects inside containers such as folders.
You may prefer to call
ItemGroup.getAllItems(Class) on AbstractProject ,
perhaps also using Util.createSubList(java.util.Collection<?>, java.lang.Class<T>) to consider only TopLevelItem s.
(That will also consider the caller's permissions.)
If you really want to get just Project s at top level, ignoring permissions,
you can filter the values from getItemMap() using Util.createSubList(java.util.Collection<?>, java.lang.Class<T>) . |
ProxyConfiguration |
getProxy()
Retrieve the proxy configuration.
|
Descriptor<Publisher> |
getPublisher(String shortClassName)
Gets the publisher descriptor by name.
|
Queue |
getQueue() |
String |
getQuietDownReason()
Returns quiet down reason if it was indicated.
|
int |
getQuietPeriod()
Gets the system default quiet period.
|
String |
getRawBuildsDir() |
String |
getRawWorkspaceDir() |
Descriptor<RepositoryBrowser<?>> |
getRepositoryBrowser(String shortClassName)
Gets the repository browser descriptor by name.
|
Descriptor<RetentionStrategy<?>> |
getRetentionStrategy(String shortClassName)
Gets the retention strategy descriptor by name.
|
File |
getRootDir()
Gets the root directory on the file system that this
Item can use freely for storing the configuration data. |
File |
getRootDirFor(TopLevelItem child)
Assigns the
root directory for children. |
FilePath |
getRootPath()
Gets the root directory of this node.
|
String |
getRootUrl()
Gets the absolute URL of Jenkins, such as
http://localhost/jenkins/ . |
String |
getRootUrlFromRequest()
Gets the absolute URL of Jenkins top page, such as
http://localhost/jenkins/ . |
Descriptor<SCM> |
getScm(String shortClassName)
Gets the SCM descriptor by name.
|
int |
getScmCheckoutRetryCount()
Gets the global SCM check out retry count.
|
CopyOnWriteList<SCMListener> |
getSCMListeners()
Deprecated.
Use
SCMListener.all() instead. |
String |
getSearchUrl()
Returns the URL of this item relative to the parent
SearchItem . |
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. |
SecretKey |
getSecretKeyAsAES128()
Deprecated.
See
getSecretKey() . |
SecurityMode |
getSecurity()
Returns the constant that captures the three basic security modes in Jenkins.
|
SecurityRealm |
getSecurityRealm() |
Descriptor<SecurityRealm> |
getSecurityRealms(String shortClassName)
Gets the
SecurityRealm descriptors by name. |
LabelAtom |
getSelfLabel()
Gets the special label that represents this node itself.
|
SetupWizard |
getSetupWizard()
If set, a currently active setup wizard - e.g.
|
int |
getSlaveAgentPort() |
View |
getStaplerFallback()
Fallback to the primary view.
|
static VersionNumber |
getStoredVersion()
Get the stored version of Jenkins, as stored by
doConfigSubmit(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse) . |
String |
getSystemMessage()
Synonym for
getDescription() . |
Object |
getTarget() |
TcpSlaveAgentListener |
getTcpSlaveAgentListener() |
Collection<String> |
getTopLevelItemNames()
Gets the names of all the
TopLevelItem s. |
TriggerDescriptor |
getTrigger(String shortClassName)
Gets the trigger descriptor by name.
|
Collection<String> |
getUnprotectedRootActions()
Gets a list of unprotected root actions.
|
UpdateCenter |
getUpdateCenter() |
String |
getUrlChildPrefix()
Gets the URL token that prefixes the URLs for child
Item s. |
User |
getUser(String name)
Gets the user of the given name.
|
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 ) |
View |
getView(String name)
Gets a view by the specified name.
|
List<Action> |
getViewActions()
Returns actions that should be displayed in views.
|
Collection<View> |
getViews()
Gets the read-only list of all
View s. |
ViewsTabBar |
getViewsTabBar()
Gets the TabBar for the views.
|
List<Widget> |
getWidgets()
Gets the
Widget s registered on this object. |
FilePath |
getWorkspaceFor(TopLevelItem item)
Returns a "workspace" directory for the given
TopLevelItem . |
boolean |
hasPeople()
Deprecated.
Potentially very expensive call; do not use from Jelly views.
|
static boolean |
isCheckURIEncodingEnabled()
Deprecated.
|
boolean |
isDefaultBuildDir()
If the configured buildsDir has it's default value or has been changed.
|
boolean |
isDisableRememberMe() |
Boolean |
isNoUsageStatistics()
If usage statistics has been disabled
|
boolean |
isQuietingDown()
Returns true if Jenkins is quieting down.
|
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. |
boolean |
isSlaveAgentPortEnforced() |
boolean |
isSubjectToMandatoryReadPermissionCheck(String restOfPath)
Test a path to see if it is subject to mandatory read permission checks by container-managed security
|
boolean |
isTerminating()
Returns true if the container initiated the termination of the web application.
|
boolean |
isUpgradedFromBefore(VersionNumber v)
Returns true if the current running Jenkins is upgraded from a version earlier than the specified version.
|
boolean |
isUsageStatisticsCollected()
If usage statistics are being collected
|
boolean |
isUseCrumbs()
If true, all the POST requests to Jenkins would have to have crumb in it to protect
Jenkins from CSRF vulnerabilities.
|
boolean |
isUseProjectNamingStrategy() |
boolean |
isUseSecurity()
A convenience method to check if there's some security
restrictions in place.
|
static <T> T |
lookup(Class<T> type)
Shortcut for
Jenkins.getInstanceOrNull()?.lookup.get(type) |
SearchIndexBuilder |
makeSearchIndex()
Default implementation that returns empty index.
|
void |
onDeleted(TopLevelItem item)
Called in response to
AbstractItem.doDoDelete(StaplerRequest, StaplerResponse) |
void |
onRenamed(TopLevelItem job,
String oldName,
String newName)
Called by
Job.renameTo(String) to update relevant data structure. |
void |
onViewRenamed(View view,
String oldName,
String newName)
View calls this method when it's renamed. |
void |
putItem(TopLevelItem item)
Overwrites the existing item by new one.
|
protected Object |
readResolve()
Maintains backwards compatibility.
|
void |
rebuildDependencyGraph()
Rebuilds the dependency map.
|
Future<DependencyGraph> |
rebuildDependencyGraphAsync()
Rebuilds the dependency map asynchronously.
|
void |
refreshExtensions()
Refresh
ExtensionList s by adding all the newly discovered extensions. |
void |
reload()
Reloads the configuration synchronously.
|
void |
remove(TopLevelItem item)
Removes an item from this group.
|
void |
removeNode(Node n)
Removes a
Node from Jenkins. |
void |
restart()
Performs a restart.
|
void |
safeRestart()
Queues up a restart to be performed once there are no builds currently running.
|
void |
save()
Save the settings to a file.
|
void |
setAgentProtocols(Set<String> protocols)
Sets the enabled agent protocols.
|
void |
setAuthorizationStrategy(AuthorizationStrategy a)
Sets a new authorization strategy.
|
void |
setCrumbIssuer(CrumbIssuer issuer) |
void |
setDisableRememberMe(boolean disableRememberMe) |
void |
setInstallState(InstallState newState)
Update the current install state.
|
void |
setJDKs(Collection<? extends JDK> jdks)
Replaces all JDK installations with those from the given collection.
|
void |
setLabelString(String label)
Sets the label string for a node.
|
void |
setMarkupFormatter(MarkupFormatter f)
Sets the markup formatter used in the system globally.
|
void |
setMode(Node.Mode m) |
void |
setMyViewsTabBar(MyViewsTabBar myViewsTabBar) |
void |
setNodeName(String name)
|
void |
setNodes(List<? extends Node> n) |
void |
setNoUsageStatistics(Boolean noUsageStatistics)
Sets the noUsageStatistics flag
|
void |
setNumExecutors(int n)
Sets a number of executors.
|
void |
setPrimaryView(View v) |
void |
setProjectNamingStrategy(ProjectNamingStrategy ns) |
void |
setProxy(ProxyConfiguration proxy)
Set the proxy configuration.
|
void |
setQuietPeriod(Integer quietPeriod)
Sets the global quiet period.
|
void |
setRawBuildsDir(String buildsDir) |
void |
setScmCheckoutRetryCount(int scmCheckoutRetryCount) |
void |
setSecurityRealm(SecurityRealm securityRealm)
Sets a security realm.
|
void |
setSlaveAgentPort(int port) |
void |
setSystemMessage(String message)
Sets the system message.
|
void |
setViews(Collection<View> views)
Completely replaces views.
|
void |
setViewsTabBar(ViewsTabBar viewsTabBar) |
boolean |
shouldShowStackTrace() |
protected void |
updateComputerList() |
boolean |
updateNode(Node n)
Saves an existing
Node on disk, called by Node.save() . |
getDisabledAdministrativeMonitors, getNodeName, getUrl, interruptReloadThread, killComputer, resetLabel, setDisabledAdministrativeMonitors, setViewOwner, updateComputerList
canTake, canTake, getAssignedLabels, getChannel, getFileSystemProvisioner, getLabelCloud, getNodeProperty, getNodeProperty, getNodePropertyDescriptors, isAcceptingTasks, isHoldOffLaunchUntilSave, reconfigure, toComputer
getSearch, getSearchIndex, getSearchName, requirePOST, sendError, sendError, sendError, sendError, sendError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allItems, allItems, allItems, getAllItems, getAllItems, getAllItems, getItemsStream, getItemsStream, getUrl
getAllViews, getUrl
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
public final transient File root
protected final transient Map<Node,Computer> computers
Computer
s in this Jenkins system. Read-only.public final Hudson.CloudList clouds
Cloud
s.@Deprecated protected transient volatile NodeList slaves
Nodes
public final transient PluginManager pluginManager
public transient volatile TcpSlaveAgentListener tcpSlaveAgentListener
@Exported public final transient OverallLoadStatistics overallLoad
@Exported public final transient LoadStatistics unlabeledLoad
Node.Mode.NORMAL
nodes and jobs that do not have any assigned nodes.public final transient NodeProvisioner unlabeledNodeProvisioner
NodeProvisioner
that reacts to unlabeledLoad
.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @Deprecated public final transient NodeProvisioner overallNodeProvisioner
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.public final transient javax.servlet.ServletContext servletContext
public final transient List<AdministrativeMonitor> administrativeMonitors
AdministrativeMonitor
s installed on this system.AdministrativeMonitor
public transient volatile ProxyConfiguration proxy
public static final Set<String> ALLOWED_RESOURCE_EXTENSIONS
doResources(StaplerRequest, StaplerResponse)
can serve.
This set is mutable to allow plugins to add additional extensions.public static List<LogRecord> logRecords
LogRecord
s produced by Jenkins.public static final com.thoughtworks.xstream.XStream XSTREAM
XStream
.public static final XStream2 XSTREAM2
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static final String UNCOMPUTED_VERSION
public static String VERSION
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String CHANGELOG_URL
public static String SESSION_HASH
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.public static String RESOURCE_PATH
Value computed in WebAppMain
.
public static String VIEW_RESOURCE_PATH
Value computed in WebAppMain
.
public static boolean PARALLEL_LOAD
public static boolean KILL_AFTER_LOAD
@Deprecated public static boolean FLYWEIGHT_SUPPORT
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @Deprecated public static boolean CONCURRENT_BUILD
AbstractProject.isConcurrentBuild()
public static boolean AUTOMATIC_SLAVE_LAUNCH
public static final PermissionGroup PERMISSIONS
public static final Permission ADMINISTER
@Restricted(value=org.kohsuke.accmod.restrictions.Beta.class) public static final Permission MANAGE
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.
public static final Permission SYSTEM_READ
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.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static final Permission[] MANAGE_AND_SYSTEM_READ
public static final Permission READ
@Deprecated public static final Permission RUN_SCRIPTS
ADMINISTER
insteadpublic 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.@Deprecated public static final Authentication ANONYMOUS
ANONYMOUS2
protected Jenkins(File root, javax.servlet.ServletContext context) throws IOException, InterruptedException, org.jvnet.hudson.reactor.ReactorException
IOException
InterruptedException
org.jvnet.hudson.reactor.ReactorException
protected Jenkins(File root, javax.servlet.ServletContext context, PluginManager pluginManager) throws IOException, InterruptedException, org.jvnet.hudson.reactor.ReactorException
pluginManager
- If non-null, use existing plugin manager. create a new one.IOException
InterruptedException
org.jvnet.hudson.reactor.ReactorException
@NonNull public static Jenkins get() throws IllegalStateException
Jenkins
singleton.Jenkins
instanceIllegalStateException
- for the reasons that getInstanceOrNull()
might return null@Deprecated @NonNull public static Jenkins getActiveInstance() throws IllegalStateException
get()
.IllegalStateException
@CLIResolver @CheckForNull public static Jenkins getInstanceOrNull()
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 master.
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 master side before constructing the callable.
If you must do a runtime check whether you are in the master 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.
Jenkins
service has not been started, or was already shut down,
or we are running on an unrelated JVM, typically an agent.@Nullable @Deprecated public static Jenkins getInstance()
getInstanceOrNull()
but with ambiguous nullability. Use get()
in typical cases.protected Object readResolve()
@CheckForNull public ProxyConfiguration getProxy()
public void setProxy(@CheckForNull ProxyConfiguration proxy)
proxy
- the proxy to set@NonNull public InstallState getInstallState()
install state
.install state
.public void setInstallState(@NonNull InstallState newState)
public TcpSlaveAgentListener getTcpSlaveAgentListener()
public org.kohsuke.stapler.framework.adjunct.AdjunctManager getAdjuncts(String dummy)
AdjunctManager
URL-bound.
The dummy parameter allows us to use different URLs for the same adjunct,
for proper cache handling.@Exported public int getSlaveAgentPort()
public boolean isSlaveAgentPortEnforced()
public void setSlaveAgentPort(int port) throws IOException
port
- 0 to indicate random available TCP port. -1 to disable this service.IOException
public Set<String> getAgentProtocols()
public void setAgentProtocols(Set<String> protocols)
protocols
- the enabled agent protocols.public void setNodeName(String name)
Node
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.
setNodeName
in class Node
public String getNodeDescription()
Node
getNodeDescription
in class Node
@Exported public String getDescription()
@NonNull public PluginManager getPluginManager()
public UpdateCenter getUpdateCenter()
@CheckForNull public Boolean isNoUsageStatistics()
public boolean isUsageStatisticsCollected()
true
if usage statistics should be collected.
Defaults to true
when noUsageStatistics
is not set.public void setNoUsageStatistics(Boolean noUsageStatistics) throws IOException
IOException
public View.People getPeople()
public View.AsynchPeople getAsynchPeople()
@Deprecated public boolean hasPeople()
View
has any associated user information recorded?public Api getApi()
@Deprecated public String getSecretKey()
ConfidentialStore
and ConfidentialKey
for how to store secrets.This value is useful for implementing some of the security features.
@Deprecated public SecretKey getSecretKeyAsAES128()
getSecretKey()
.public String getLegacyInstanceId()
This form of identifier is weak in that it can be impersonated by others. See https://wiki.jenkins-ci.org/display/JENKINS/Instance+Identity for more modern form of instance ID that can be challenged and verified.
public Descriptor<SCM> getScm(String shortClassName)
public Descriptor<RepositoryBrowser<?>> getRepositoryBrowser(String shortClassName)
public Descriptor<Builder> getBuilder(String shortClassName)
public Descriptor<BuildWrapper> getBuildWrapper(String shortClassName)
public Descriptor<Publisher> getPublisher(String shortClassName)
public TriggerDescriptor getTrigger(String shortClassName)
public Descriptor<RetentionStrategy<?>> getRetentionStrategy(String shortClassName)
public JobPropertyDescriptor getJobProperty(String shortClassName)
JobPropertyDescriptor
by name. Primarily used for making them web-visible.@Deprecated public ComputerSet getComputer()
public Descriptor getDescriptor(String id)
Descriptor
by its name to URL.
After doing all the getXXX(shortClassName)
methods, I finally realized that
this just doesn't scale.id
- Either Descriptor.getId()
(recommended) or the short name of a Describable
subtype (for compatibility)IllegalArgumentException
- if a short name was passed which matches multiple IDs (fail fast)public Descriptor getDescriptorByName(String id)
getDescriptor(String)
.getDescriptorByName
in interface DescriptorByNameOwner
id
- Either Descriptor.getId()
(recommended) or the short name.@CheckForNull public Descriptor getDescriptor(Class<? extends Describable> type)
Descriptor
that corresponds to the given Describable
type.
If you have an instance of type
and call Describable.getDescriptor()
,
you'll get the same instance that this method returns.
@NonNull public Descriptor getDescriptorOrDie(Class<? extends Describable> type)
getDescriptor(Class)
but don't take no for an answer.AssertionError
- If the descriptor is missing.public <T extends Descriptor> T getDescriptorByType(Class<T> type)
Descriptor
instance in the current Jenkins by its type.public Descriptor<SecurityRealm> getSecurityRealms(String shortClassName)
SecurityRealm
descriptors by name. Primarily used for making them web-visible.protected void updateComputerList()
@Deprecated public CopyOnWriteList<SCMListener> getSCMListeners()
SCMListener.all()
instead.@CheckForNull public Plugin getPlugin(String shortName)
hudson/plugin/ID
to be served by the views
of the plugin class.shortName
- Short name of the pluginnull
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.@CheckForNull public <P extends Plugin> P getPlugin(Class<P> clazz)
This allows easy storage of plugin information in the plugin singleton without every plugin reimplementing the singleton pattern.
P
- Class of the pluginclazz
- 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)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.public <P extends Plugin> List<P> getPlugins(Class<P> clazz)
clazz
- The plugin class (beware class-loader fun)public String getSystemMessage()
getDescription()
.@NonNull public MarkupFormatter getMarkupFormatter()
public void setMarkupFormatter(MarkupFormatter f)
public void setSystemMessage(String message) throws IOException
IOException
@StaplerDispatchable public FederatedLoginService getFederatedLoginService(String name)
public List<FederatedLoginService> getFederatedLoginServices()
public Launcher createLauncher(TaskListener listener)
Node
Launcher
for executing programs on this node.
The callee must call Launcher.decorateFor(Node)
before returning to complete the decoration.
createLauncher
in class Node
public String getFullName()
ItemGroup
ItemGroup
.getFullName
in interface ItemGroup<TopLevelItem>
Item.getFullName()
public String getFullDisplayName()
getFullDisplayName
in interface ItemGroup<TopLevelItem>
Item.getFullDisplayName()
public List<Action> getActions()
Action
s 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(...)
.
@Exported(name="jobs") public List<TopLevelItem> getItems()
Jenkins
.getItems
in interface ItemGroup<TopLevelItem>
ItemGroup.getAllItems(Class)
public List<TopLevelItem> getItems(Predicate<TopLevelItem> pred)
Jenkins
based on supplied predicate.getItems
in interface ItemGroup<TopLevelItem>
ItemGroup.getAllItems(Class)
public Map<String,TopLevelItem> getItemMap()
TopLevelItem
s keyed by their names.
This method is efficient, as it doesn't involve any copying.
public <T> List<T> getItems(Class<T> type)
Jenkins
but of the given type.@Deprecated public List<Project> getProjects()
ItemGroup.getAllItems(Class)
on AbstractProject
,
perhaps also using Util.createSubList(java.util.Collection<?>, java.lang.Class<T>)
to consider only TopLevelItem
s.
(That will also consider the caller's permissions.)
If you really want to get just Project
s at top level, ignoring permissions,
you can filter the values from getItemMap()
using Util.createSubList(java.util.Collection<?>, java.lang.Class<T>)
.public Collection<String> getJobNames()
Job
s.public List<Action> getViewActions()
ViewGroup
In this interface, the return value is used read-only. This doesn't prevent subtypes from returning modifiable actions, however.
getViewActions
in interface ViewGroup
getActions()
by defaultActionable.getActions()
public Collection<String> getTopLevelItemNames()
TopLevelItem
s.@CheckForNull public View getView(@CheckForNull String name)
ViewGroup
s if required.@Exported public Collection<View> getViews()
View
s.public void addView(View v) throws IOException
ModifiableViewGroup
addView
in interface ModifiableViewGroup
IOException
public void setViews(Collection<View> views) throws IOException
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
IOException
public boolean canDelete(View view)
ViewGroup
public void deleteView(View view) throws IOException
ViewGroup
deleteView
in interface ViewGroup
IOException
public void onViewRenamed(View view, String oldName, String newName)
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.
onViewRenamed
in interface ViewGroup
@Exported public View getPrimaryView()
View
that renders the top-page of Jenkins.getPrimaryView
in interface ViewGroup
public void setPrimaryView(@NonNull View v)
public ViewsTabBar getViewsTabBar()
ViewGroup
getViewsTabBar
in interface ViewGroup
public void setViewsTabBar(ViewsTabBar viewsTabBar)
public Jenkins getItemGroup()
ViewGroup
ItemGroup
from which the views in this group should render items.
Generally speaking, Views render a subset of TopLevelItem
s that belong to this item group.
getItemGroup
in interface ViewGroup
ModifiableItemGroup
(if the container allows arbitrary addition).
By default, getInstance()
.public MyViewsTabBar getMyViewsTabBar()
public void setMyViewsTabBar(MyViewsTabBar myViewsTabBar)
public boolean isUpgradedFromBefore(VersionNumber v)
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.*"
@CLIResolver @CheckForNull public Computer getComputer(@NonNull String name)
public Label getLabel(String expr)
(String)
@Nullable public LabelAtom getLabelAtom(@CheckForNull String name)
public Queue getQueue()
getQueue
in class AbstractCIBase
public String getDisplayName()
getDisplayName
in interface ModelObject
getDisplayName
in class Node
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void setJDKs(Collection<? extends JDK> jdks)
JDK.DescriptorImpl.setInstallations(JDK...)
to
set JDK installations from external code.@CheckForNull public Node getNode(String name)
protected Map<Node,Computer> getComputerMap()
getComputerMap
in class AbstractCIBase
@NonNull public List<Node> getNodes()
getNodes
in class AbstractCIBase
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public Nodes getNodesObject()
public void addNode(Node n) throws IOException
Node
to Jenkins.
If a node of the same name already exists then that node will be replaced.IOException
public void removeNode(@NonNull Node n) throws IOException
Node
from Jenkins.IOException
public boolean updateNode(Node n) throws IOException
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.n
- the node to be updated.true
, if the node was updated. false
, if the node was not in the list of nodes.IOException
- if the node could not be persisted.Nodes.updateNode(hudson.model.Node)
public void setNodes(List<? extends Node> n) throws IOException
IOException
public DescribableList<NodeProperty<?>,NodePropertyDescriptor> getNodeProperties()
Node
NodeProperty
instances configured for this Node
.getNodeProperties
in class Node
public DescribableList<NodeProperty<?>,NodePropertyDescriptor> getGlobalNodeProperties()
@CheckForNull public AdministrativeMonitor getAdministrativeMonitor(String id)
AdministrativeMonitor
s to URL.id
- Monitor IDnull
if it does not existpublic List<AdministrativeMonitor> getActiveAdministrativeMonitors()
public NodeDescriptor getDescriptor()
Describable
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.)
getDescriptor
in interface Describable<Node>
getDescriptor
in class Node
public int getQuietPeriod()
public void setQuietPeriod(Integer quietPeriod) throws IOException
quietPeriod
- null to the default value.IOException
public int getScmCheckoutRetryCount()
public void setScmCheckoutRetryCount(int scmCheckoutRetryCount) throws IOException
IOException
public String getSearchUrl()
SearchItem
SearchItem
.getSearchUrl
in interface SearchItem
getSearchUrl
in class Node
public SearchIndexBuilder makeSearchIndex()
AbstractModelObject
makeSearchIndex
in class AbstractModelObject
public String getUrlChildPrefix()
ItemGroup
Item
s.
Like "job", "item", etc.getUrlChildPrefix
in interface ItemGroup<TopLevelItem>
@Nullable public String getRootUrl() throws IllegalStateException
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.
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 /
IllegalStateException
- JenkinsLocationConfiguration
cannot be retrieved.
Jenkins instance may be not ready, or there is an extension loading glitch.@Exported(name="url") @Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) @CheckForNull public String getConfiguredRootUrl()
JenkinsLocationConfiguration.getUrl()
.public boolean isRootUrlSecure()
ServletRequest.isSecure()
because HTTPS might be terminated
in the reverse proxy.@NonNull public String getRootUrlFromRequest()
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.
Running Jenkins behind Apache
shows some examples of configuration.
public File getRootDir()
PersistenceRoot
Item
can use freely for storing the configuration data.
This parameter is given by the ItemGroup
when
Item
is loaded from memory.
getRootDir
in interface PersistenceRoot
public FilePath getWorkspaceFor(TopLevelItem item)
Node
TopLevelItem
.
Workspace directory is usually used for keeping out the checked out source code, but it can be used for anything.
getWorkspaceFor
in class Node
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isDefaultBuildDir()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String expandVariablesForDirectory(String base, String itemFullName, String itemRootDir)
public String getRawWorkspaceDir()
public String getRawBuildsDir()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void setRawBuildsDir(String buildsDir)
@NonNull public FilePath getRootPath()
Node
Hudson always owns a directory on every node. This method returns that.
getRootPath
in class Node
FilePath
object is not available.public FilePath createPath(String absolutePath)
Node
FilePath
on this node.createPath
in class Node
public ClockDifference getClockDifference()
Node
getClockDifference
in class Node
public hudson.remoting.Callable<ClockDifference,IOException> getClockDifferenceCallable()
Node
Callable
that when run on the channel, estimates the clock difference.getClockDifferenceCallable
in class Node
public LogRecorderManager getLog()
LogRecorderManager
to "/log".
Everything below here is admin-only, so do the check here.@Exported public boolean isUseSecurity()
public boolean isUseProjectNamingStrategy()
@Exported public boolean isUseCrumbs()
public SecurityMode getSecurity()
public SecurityRealm getSecurityRealm()
public void setSecurityRealm(@CheckForNull SecurityRealm securityRealm)
securityRealm
- Security realm to set.
If null
, SecurityRealm.NO_AUTHENTICATION
will be set.public void setAuthorizationStrategy(@CheckForNull AuthorizationStrategy a)
a
- Authorization strategy to set.
If null
, AuthorizationStrategy.UNSECURED
will be setpublic boolean isDisableRememberMe()
public void setDisableRememberMe(boolean disableRememberMe)
public void disableSecurity()
public void setProjectNamingStrategy(ProjectNamingStrategy ns)
public Lifecycle getLifecycle()
@CheckForNull public com.google.inject.Injector getInjector()
public <T> ExtensionList<T> getExtensionList(Class<T> extensionType)
ExtensionList
that retains the discovered instances for the given extension type.extensionType
- The base type that represents the extension point. Normally ExtensionPoint
subtype
but that's not a hard requirement.ExtensionList.lookup(java.lang.Class<T>)
@StaplerDispatchable public ExtensionList getExtensionList(String extensionType) throws ClassNotFoundException
ExtensionList
s to URLs.ClassNotFoundException
@NonNull public <T extends Describable<T>,D extends Descriptor<T>> DescriptorExtensionList<T,D> getDescriptorList(Class<T> type)
ExtensionList
that retains the discovered Descriptor
instances for the given
kind of Describable
.public void refreshExtensions() throws ExtensionRefreshException
ExtensionList
s by adding all the newly discovered extensions.
Exposed only for PluginManager.dynamicLoad(File)
.ExtensionRefreshException
public ACL getACL()
ACL
.getACL
in interface AccessControlled
getACL
in class Node
AuthorizationStrategy.getRootACL()
public AuthorizationStrategy getAuthorizationStrategy()
public ProjectNamingStrategy getProjectNamingStrategy()
null
@Exported public boolean isQuietingDown()
No further jobs will be executed unless it can be finished while other current pending builds are still in progress.
@Exported @CheckForNull public String getQuietDownReason()
public boolean isTerminating()
public InitMilestone getInitLevel()
InitMilestone.STARTED
even if the initialization hasn't been started, so that this method
never returns null.public void setNumExecutors(int n) throws IOException, IllegalArgumentException
n
- Number of executorsIOException
- Failed to save the configurationIllegalArgumentException
- Negative value has been passedpublic TopLevelItem getItem(String name) throws org.springframework.security.access.AccessDeniedException
Item
inside this group that has a given name, or null if it does not exist..
Note that the look up is case-insensitive.getItem
in interface ItemGroup<TopLevelItem>
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 itorg.springframework.security.access.AccessDeniedException
- if the current user has Item.DISCOVER
but not Item.READ
on this itempublic Item getItem(String pathName, ItemGroup context)
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>)
.
context
- null is interpreted as Jenkins
. Base 'directory' of the interpretation.public final <T extends Item> T getItem(String pathName, ItemGroup context, @NonNull Class<T> type)
public File getRootDirFor(TopLevelItem child)
ItemGroup
root directory
for children.getRootDirFor
in interface ItemGroup<TopLevelItem>
@CheckForNull public <T extends Item> T getItemByFullName(@NonNull String fullName, Class<T> type) throws org.springframework.security.access.AccessDeniedException
Item
object by its full name.
Full names are like path names, where each name of Item
is
combined by '/'.Item
doesn't exist under the given full name,
or it exists but it's no an instance of the given type.org.springframework.security.access.AccessDeniedException
- as per ItemGroup.getItem(java.lang.String)
@CheckForNull public User getUser(String name)
User.get(String,boolean)
,
User.getById(String, boolean)
public TopLevelItem createProject(TopLevelItemDescriptor type, String name) throws IOException
IOException
public TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify) throws IOException
ModifiableTopLevelItemGroup
createProject
in interface ModifiableTopLevelItemGroup
type
- Descriptor for job typename
- Name for jobnotify
- Whether to fire onCreated method for all ItemListenersIOException
public void putItem(TopLevelItem item) throws IOException, InterruptedException
This is a short cut for deleting an existing job and adding a new one.
IOException
InterruptedException
public <T extends TopLevelItem> T createProject(Class<T> type, String name) throws IOException
This version infers the descriptor from the type of the top-level item.
IllegalArgumentException
- if the project of the given name already exists.IOException
public void onRenamed(TopLevelItem job, String oldName, String newName) throws IOException
Job.renameTo(String)
to update relevant data structure.
assumed to be synchronized on Jenkins by the caller.onRenamed
in interface ItemGroup<TopLevelItem>
IOException
public void onDeleted(TopLevelItem item) throws IOException
AbstractItem.doDoDelete(StaplerRequest, StaplerResponse)
onDeleted
in interface ItemGroup<TopLevelItem>
IOException
public boolean canAdd(TopLevelItem item)
DirectlyModifiableTopLevelItemGroup
canAdd
in interface DirectlyModifiableTopLevelItemGroup
item
- an item currently elsewhereDirectlyModifiableTopLevelItemGroup.add(I, java.lang.String)
may be called with this itempublic <I extends TopLevelItem> I add(I item, String name) throws IOException, IllegalArgumentException
DirectlyModifiableTopLevelItemGroup
putItem(hudson.model.TopLevelItem)
this does not try to call Item.delete()
on an existing item, nor does it fire ItemListener.onCreated(hudson.model.Item)
, nor check permissions.
Normally you would call Item.onLoad(hudson.model.ItemGroup<? extends hudson.model.Item>, java.lang.String)
after calling this method (the implementation is not expected to do so).add
in interface DirectlyModifiableTopLevelItemGroup
I
- the kind of itemitem
- an item to add which is currently elsewherename
- the desired item name in this group (might simply be the original Item.getName()
)item
, but might be a new copy if necessaryIOException
- if adding failsIllegalArgumentException
- if DirectlyModifiableTopLevelItemGroup.canAdd(hudson.model.TopLevelItem)
is false, or an item with this name already exists, or this item is as yet unnamedpublic void remove(TopLevelItem item) throws IOException, IllegalArgumentException
DirectlyModifiableTopLevelItemGroup
ItemGroup.onDeleted(T)
this is not expected to fire any events.remove
in interface DirectlyModifiableTopLevelItemGroup
item
- an item which was part of this groupIOException
- if removing failsIllegalArgumentException
- if this was not part of the group to begin withpublic FingerprintMap getFingerprintMap()
@StaplerDispatchable public Object getFingerprint(String md5sum) throws IOException
IOException
public Fingerprint _getFingerprint(String md5sum) throws IOException
Fingerprint
object if it exists.
Otherwise null.IOException
public int getNumExecutors()
Node
Executor
s.
This may be different from getExecutors().size()
because it takes time to adjust the number of executors.getNumExecutors
in class Node
public Node.Mode getMode()
Node
Node.Mode.EXCLUSIVE
if this node is only available
for those jobs that exclusively specifies this node
as the assigned node.public void setMode(Node.Mode m) throws IOException
IOException
public String getLabelString()
Node
Node.getAssignedLabels()
and includes all labels that have been
manually configured.
Mainly for form binding.getLabelString
in class Node
public void setLabelString(String label) throws IOException
Node
Node.getLabelString()
.setLabelString
in class Node
label
- The new label string to use.IOException
public LabelAtom getSelfLabel()
Node
getSelfLabel
in class Node
@NonNull public Computer createComputer()
Node
Computer
object that acts as the UI peer of this Node
.
Nobody but updateComputerList()
should call this method.createComputer
in class Node
null
if the Node
implementation does not support it (e.g. Cloud
agent).public void save() throws IOException
save
in interface Saveable
save
in class Node
IOException
- if the persistence failed.public void cleanUp()
@POST public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException
IOException
javax.servlet.ServletException
Descriptor.FormException
@CheckForNull public CrumbIssuer getCrumbIssuer()
CrumbIssuer
currently in use.public void setCrumbIssuer(CrumbIssuer issuer)
public void doTestPost(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
@POST public void doConfigExecutorsSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException
IOException
javax.servlet.ServletException
Descriptor.FormException
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public org.kohsuke.stapler.HttpRedirect doQuietDown()
@Deprecated public org.kohsuke.stapler.HttpRedirect doQuietDown(boolean block, int timeout)
doQuietDown(boolean, int, String)
instead.block
- Block until the system really quiets down and no builds are runningtimeout
- If non-zero, only block up to the specified number of millisecondspublic org.kohsuke.stapler.HttpRedirect doQuietDown(@QueryParameter boolean block, @QueryParameter int timeout, @QueryParameter @CheckForNull String reason) throws InterruptedException, IOException
block
- Block until the system really quiets down and no builds are runningtimeout
- If non-zero, only block up to the specified number of millisecondsreason
- Quiet reason that will be visible to userInterruptedException
IOException
public org.kohsuke.stapler.HttpRedirect doCancelQuietDown()
public org.kohsuke.stapler.HttpResponse doToggleCollapse() throws javax.servlet.ServletException, IOException
javax.servlet.ServletException
IOException
public void doClassicThreadDump(org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public Map<String,Map<String,String>> getAllThreadDumps() throws IOException, InterruptedException
Since this is for diagnostics, it has a built-in precautionary measure against hang agents.
IOException
InterruptedException
public TopLevelItem doCreateItem(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
ModifiableItemGroup
<n:form xmlns:n="/lib/form">
.doCreateItem
in interface ModifiableItemGroup<TopLevelItem>
IOException
javax.servlet.ServletException
public TopLevelItem createProjectFromXML(String name, InputStream xml) throws IOException
ModifiableTopLevelItemGroup
createProjectFromXML
in interface ModifiableTopLevelItemGroup
name
- Name of the newly created project.xml
- Item configuration as xmlTopLevelItem
.IOException
public <T extends TopLevelItem> T copy(T src, String name) throws IOException
ModifiableTopLevelItemGroup
copy
in interface ModifiableTopLevelItemGroup
src
- A TopLevelItem
to be copied.name
- Name of the newly created project.TopLevelItem
.IOException
public <T extends AbstractProject<?,?>> T copy(T src, String name) throws IOException
IOException
@POST public void doCreateView(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException
IOException
javax.servlet.ServletException
Descriptor.FormException
public static void checkGoodName(String name) throws Failure
Failure
- if the given name is not goodpublic void doSecured(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
BasicAuthenticationFilter
public void doLoginEntry(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
LegacySecurityRealm
.IOException
public void doLogout(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public Slave.JnlpJar getJnlpJars(String fileName)
public Slave.JnlpJar doJnlpJars(org.kohsuke.stapler.StaplerRequest req)
public org.kohsuke.stapler.HttpResponse doReload() throws IOException
IOException
public void reload() throws IOException, InterruptedException, org.jvnet.hudson.reactor.ReactorException
ItemListener.onLoaded()
nor Initializer
s.IOException
InterruptedException
org.jvnet.hudson.reactor.ReactorException
public void doDoFingerprintCheck(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doGc(org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
@StaplerDispatchable public void doException()
public ModelObjectWithContextMenu.ContextMenu doContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws IOException, org.apache.commons.jelly.JellyException
ModelObjectWithContextMenu
return new ContextMenu().from(this,request,response);
,
which implements the default behaviour. See ModelObjectWithContextMenu.ContextMenu.from(ModelObjectWithContextMenu, StaplerRequest, StaplerResponse)
for more details of what it does. This should suit most implementations.doContextMenu
in interface ModelObjectWithContextMenu
IOException
org.apache.commons.jelly.JellyException
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
ModelObjectWithChildren
doChildrenContextMenu
in interface ModelObjectWithChildren
Exception
public RemotingDiagnostics.HeapDump getHeapDump() throws IOException
IOException
public void doSimulateOutOfMemory() throws IOException
IOException
public DirectoryBrowserSupport doUserContent()
@CLIMethod(name="restart") public void doRestart(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, RestartNotSupportedException
HudsonIsRestarting
IOException
javax.servlet.ServletException
RestartNotSupportedException
@CLIMethod(name="safe-restart") public org.kohsuke.stapler.HttpResponse doSafeRestart(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException, RestartNotSupportedException
HudsonIsRestarting
IOException
javax.servlet.ServletException
RestartNotSupportedException
public void restart() throws RestartNotSupportedException
RestartNotSupportedException
public void safeRestart() throws RestartNotSupportedException
RestartNotSupportedException
@CLIMethod(name="shutdown") public void doExit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
@CLIMethod(name="safe-shutdown") public org.kohsuke.stapler.HttpResponse doSafeExit(org.kohsuke.stapler.StaplerRequest req) throws IOException
IOException
@NonNull public static org.springframework.security.core.Authentication getAuthentication2()
Authentication
object that represents the user
associated with the current request.@Deprecated @NonNull public static Authentication getAuthentication()
getAuthentication2()
public void doScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doScriptText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
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
IOException
javax.servlet.ServletException
public void doEval(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doSignup(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doIconSize(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doFingerprintCleanup(org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
public void doWorkspaceCleanup(org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
public FormValidation doDefaultJDKCheck(org.kohsuke.stapler.StaplerRequest request, @QueryParameter String value)
public FormValidation doCheckViewName(@QueryParameter String value)
@Deprecated public FormValidation doViewExistsCheck(@QueryParameter String value)
public void doResources(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
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.
IOException
javax.servlet.ServletException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince(value="2.37") @Deprecated public FormValidation doCheckURIEncoding(org.kohsuke.stapler.StaplerRequest request) throws IOException
IOException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince(value="2.37") @Deprecated public static boolean isCheckURIEncodingEnabled()
public void rebuildDependencyGraph()
public Future<DependencyGraph> rebuildDependencyGraphAsync()
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.
public DependencyGraph getDependencyGraph()
public List<ManagementLink> getManagementLinks()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public Map<ManagementLink.Category,List<ManagementLink>> getCategorizedManagementLinks()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public SetupWizard getSetupWizard()
public User getMe()
/me
URL.@StaplerDispatchable public List<Widget> getWidgets()
Widget
s 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()
.
public Object getTarget()
getTarget
in interface org.kohsuke.stapler.StaplerProxy
public boolean isSubjectToMandatoryReadPermissionCheck(String restOfPath)
restOfPath
- the URI, excluding the Jenkins root URI and query stringpublic Collection<String> getUnprotectedRootActions()
getTarget()
.public View getStaplerFallback()
getStaplerFallback
in interface org.kohsuke.stapler.StaplerFallback
public FormValidation doCheckDisplayName(@QueryParameter String displayName, @QueryParameter String jobName)
displayName
- The display name to testjobName
- The name of the job the user is configuring@CheckForNull public static <T> T lookup(Class<T> type)
Jenkins.getInstanceOrNull()?.lookup.get(type)
@CheckForNull public static VersionNumber getVersion()
VERSION
into VersionNumber
, or null if it's not parseable as a version number
(such as when Jenkins is run with mvn jetty:run
)@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @CheckForNull public static VersionNumber getStoredVersion()
doConfigSubmit(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)
.
Parses the version into VersionNumber
, or null if it's not parseable as a version number
(such as when Jenkins is run with mvn jetty:run
)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean shouldShowStackTrace()
Copyright © 2004–2021. All rights reserved.