Class MailAddressResolver
- All Implemented Interfaces:
ExtensionPoint
This is an extension point of Jenkins. Plugins that contribute a new implementation
of this class should put Extension
on your implementation class, like this:
@Extension
class MyMailAddressResolver extends MailAddressResolver
{
...
}
Techniques
User identity in Jenkins is global, and not specific to a particular job. As a result, mail address resolution
only receives User
, which by itself doesn't really have that much information in it.
So the common technique for a mail address resolution is to define your own UserProperty
types and
add it to User
objects where more context is available. For example, an SCM
implementation
can have a lot more information about a particular user during a check out, so that would be a good place
to capture information as UserProperty
, which then later used by a MailAddressResolver
.
Performance considerations
Mail address resolution is a potentially time consuming process. It can considerably slow down operations relaying on mail address resolution, especially on Jenkins instances having registered several resolvers. Searching through all projects is generally a bad idea. See JENKINS-16437 for more details.
- Since:
- 1.192
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<MailAddressResolver>
all()
abstract String
Infers e-mail address of the given user.static String
Try to resolve email address using resolvers.static String
resolveFast
(User u) Try to resolve user email address fast enough to be used from UI
-
Field Details
-
LIST
All registeredMailAddressResolver
implementations.
-
-
Constructor Details
-
MailAddressResolver
public MailAddressResolver()
-
-
Method Details
-
findMailAddressFor
Infers e-mail address of the given user.This method is called when a
User
without explicitly configured e-mail address is used, as an attempt to infer e-mail address.The normal strategy is to look at
the projects that the user is participating
, then use the repository information to infer the e-mail address.When multiple resolvers are installed, they are consulted in order and the search will be over when an address is inferred by someone.
Since
MailAddressResolver
is singleton, this method can be invoked concurrently from multiple threads.- Parameters:
u
- a given user to resolve address for- Returns:
- null if the inference failed.
-
resolve
Try to resolve email address using resolvers. If a user specifies a MailUserProperty
, then it will be used with the highest priority.- Parameters:
u
- user to resolve address for- Returns:
- User address or null if resolution failed
-
resolveFast
Try to resolve user email address fast enough to be used from UIThis implementation does not trigger
MailAddressResolver
extension point.- Parameters:
u
- A user, for whom the email should be resolved- Returns:
- User address or null if resolution failed
-
all
- Returns:
- all the registered
MailAddressResolver
descriptors.
-
all()
for read access andExtension
for registration.