mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-21 15:55:40 +00:00
updated Job to support auto discovery
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15670 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
f24fadef87
commit
0b5601aa5d
10 files changed
+53
-35
No files matched your search
@@ -27,6 +27,7 @@ import hudson.CopyOnWrite;
|
||||
import hudson.FilePath;
|
||||
import hudson.XmlFile;
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Action;
|
||||
import hudson.model.DependencyGraph;
|
||||
@@ -545,6 +546,7 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
|
||||
|
||||
public static final class DescriptorImpl extends TopLevelItemDescriptor {
|
||||
|
||||
@@ -638,6 +638,7 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
|
||||
|
||||
public static final class DescriptorImpl extends TopLevelItemDescriptor {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package hudson.model;
|
||||
|
||||
import hudson.model.RunMap.Constructor;
|
||||
import hudson.Extension;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
@@ -109,6 +110,7 @@ public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements Top
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final TopLevelItemDescriptor DESCRIPTOR = new DescriptorImpl();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package hudson.model;
|
||||
|
||||
import hudson.FilePath;
|
||||
import hudson.Extension;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -95,6 +96,7 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
|
||||
|
||||
public static final class DescriptorImpl extends TopLevelItemDescriptor {
|
||||
|
||||
@@ -505,10 +505,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
|
||||
// if we are loading old data that doesn't have this field
|
||||
if(slaves==null) slaves = new NodeList();
|
||||
|
||||
// work around to have MavenModule register itself until we either move it to a plugin
|
||||
// or make it a part of the core.
|
||||
Items.LIST.hashCode();
|
||||
|
||||
adjuncts = new AdjunctManager(servletContext, pluginManager.uberClassLoader,"adjuncts/"+VERSION_HASH);
|
||||
|
||||
load();
|
||||
|
||||
@@ -25,6 +25,9 @@ package hudson.model;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import hudson.XmlFile;
|
||||
import hudson.DescriptorExtensionList;
|
||||
import hudson.Extension;
|
||||
import hudson.scm.RepositoryBrowser;
|
||||
import hudson.matrix.MatrixProject;
|
||||
import hudson.matrix.MatrixConfiguration;
|
||||
import hudson.matrix.Axis;
|
||||
@@ -32,6 +35,7 @@ import hudson.maven.MavenModule;
|
||||
import hudson.maven.MavenModuleSet;
|
||||
import hudson.maven.ModuleDependency;
|
||||
import hudson.util.XStream2;
|
||||
import hudson.util.DescriptorList;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -48,16 +52,21 @@ import java.util.StringTokenizer;
|
||||
public class Items {
|
||||
/**
|
||||
* List of all installed {@link TopLevelItem} types.
|
||||
*
|
||||
* @deprecated as of 1.286
|
||||
* Use {@link #all()} for read access and {@link Extension} for registration.
|
||||
*/
|
||||
public static final List<TopLevelItemDescriptor> LIST = Descriptor.toList(
|
||||
FreeStyleProject.DESCRIPTOR,
|
||||
MavenModuleSet.DESCRIPTOR,
|
||||
MatrixProject.DESCRIPTOR,
|
||||
ExternalJob.DESCRIPTOR
|
||||
);
|
||||
public static final List<TopLevelItemDescriptor> LIST = (List)new DescriptorList<TopLevelItem>(TopLevelItem.class);
|
||||
|
||||
/**
|
||||
* Returns all the registered {@link TopLevelItemDescriptor}s.
|
||||
*/
|
||||
public static DescriptorExtensionList<TopLevelItem,TopLevelItemDescriptor> all() {
|
||||
return Hudson.getInstance().getDescriptorList(TopLevelItem.class);
|
||||
}
|
||||
|
||||
public static TopLevelItemDescriptor getDescriptor(String fqcn) {
|
||||
return Descriptor.find(LIST,fqcn);
|
||||
return Descriptor.find(all(),fqcn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,7 +102,7 @@ import org.kohsuke.stapler.export.Exported;
|
||||
* Every time it "runs", it will be recorded as a {@link Run} object.
|
||||
*
|
||||
* <p>
|
||||
* To create a custom job type, add it to {@link Items#LIST}.
|
||||
* To create a custom job type, extend {@link TopLevelItemDescriptor} and put {@link Extension} on it.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
package hudson.model;
|
||||
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.Extension;
|
||||
|
||||
/**
|
||||
* {@link Item} that can be directly displayed under {@link Hudson}.
|
||||
*
|
||||
* <p>
|
||||
* To register a custom {@link TopLevelItem} class from a plugin, add it to
|
||||
* {@link Items#LIST}. Also see {@link Items#XSTREAM}.
|
||||
* To register a custom {@link TopLevelItem} class from a plugin, put {@link Extension} on your
|
||||
* {@link TopLevelItemDescriptor}. Also see {@link Items#XSTREAM}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,6 @@ package hudson.model;
|
||||
import com.trilead.ssh2.crypto.Base64;
|
||||
import hudson.PluginWrapper;
|
||||
import hudson.Util;
|
||||
import hudson.node_monitors.ArchitectureMonitor;
|
||||
import hudson.node_monitors.ArchitectureMonitor.DescriptorImpl;
|
||||
import static hudson.util.TimeUnit2.DAYS;
|
||||
import net.sf.json.JSONObject;
|
||||
@@ -160,7 +159,7 @@ public class UsageStatistics extends PageDecorator {
|
||||
|
||||
JSONObject jobs = new JSONObject();
|
||||
List<TopLevelItem> items = h.getItems();
|
||||
for (TopLevelItemDescriptor d : Items.LIST) {
|
||||
for (TopLevelItemDescriptor d : Items.all()) {
|
||||
int cnt=0;
|
||||
for (TopLevelItem item : items) {
|
||||
if(item.getDescriptor()==d)
|
||||
|
||||
@@ -23,34 +23,34 @@
|
||||
*/
|
||||
package hudson.tasks;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.ExtensionListView;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.Plugin;
|
||||
import hudson.scm.SCM;
|
||||
import hudson.scm.CVSSCM;
|
||||
import hudson.scm.SubversionSCM;
|
||||
import hudson.model.User;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.User;
|
||||
import hudson.scm.CVSSCM;
|
||||
import hudson.scm.SCM;
|
||||
import hudson.scm.SubversionSCM;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Infers e-mail addresses for the user when none is specified.
|
||||
*
|
||||
* <p>
|
||||
* This is an extension point of Hudson. Plugins tha contribute new implementation
|
||||
* of this class must register it to {@link #LIST}. The typical way to do this is:
|
||||
* of this class should put {@link Extension} on your implementation class, like this:
|
||||
*
|
||||
* <pre>
|
||||
* class PluginImpl extends {@link Plugin} {
|
||||
* public void start() {
|
||||
* ...
|
||||
* MailAddressResolver.LIST.add(new MyMailAddressResolver());
|
||||
* }
|
||||
* @Extension
|
||||
* class MyMailAddressResolver extends {@link MailAddressResolver} {
|
||||
* ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
@@ -83,7 +83,7 @@ public abstract class MailAddressResolver implements ExtensionPoint {
|
||||
public abstract String findMailAddressFor(User u);
|
||||
|
||||
public static String resolve(User u) {
|
||||
for (MailAddressResolver r : LIST) {
|
||||
for (MailAddressResolver r : all()) {
|
||||
String email = r.findMailAddressFor(u);
|
||||
if(email!=null) return email;
|
||||
}
|
||||
@@ -123,12 +123,17 @@ public abstract class MailAddressResolver implements ExtensionPoint {
|
||||
|
||||
/**
|
||||
* All registered {@link MailAddressResolver} implementations.
|
||||
*
|
||||
* @deprecated as of 1.286
|
||||
* Use {@link #all()} for read access and {@link Extension} for registration.
|
||||
*/
|
||||
public static final List<MailAddressResolver> LIST = new CopyOnWriteArrayList<MailAddressResolver>();
|
||||
public static final List<MailAddressResolver> LIST = ExtensionListView.createList(MailAddressResolver.class);
|
||||
|
||||
static {
|
||||
// register built-in instances
|
||||
LIST.add(new DefaultAddressResolver());
|
||||
/**
|
||||
* Returns all the registered {@link MailAddressResolver} descriptors.
|
||||
*/
|
||||
public static ExtensionList<MailAddressResolver> all() {
|
||||
return Hudson.getInstance().getExtensionList(MailAddressResolver.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,6 +143,7 @@ public abstract class MailAddressResolver implements ExtensionPoint {
|
||||
* Since this has low UI visibility, we are open to having a large number of rules here.
|
||||
* If you'd like to add one, please contribute more rules.
|
||||
*/
|
||||
@Extension
|
||||
public static class DefaultAddressResolver extends MailAddressResolver {
|
||||
public String findMailAddressFor(User u) {
|
||||
for (AbstractProject<?,?> p : u.getProjects()) {
|
||||
|
||||
Reference in new issue
Block a user