Permalink
Browse files

Plugin created and some initial groundwork for finding SCM plugins co…

…mpleted.
  • Loading branch information...
0 parents commit f2ee044b69db51b86b04126a2cb65b34d25b0475 @kmbell kmbell committed Feb 18, 2011
Oops, something went wrong.
@@ -0,0 +1,2 @@
+glob:target/*
+glob:work/*
@@ -0,0 +1,13 @@
+<projectDescription>
+ <name>multiscm</name>
+ <comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,5 @@
+#Thu Feb 17 14:25:30 CST 2011
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
29 pom.xml
@@ -0,0 +1,29 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jvnet.hudson.plugins</groupId>
+ <artifactId>plugin</artifactId>
+ <version>1.377</version><!-- which version of Hudson is this plugin built against? -->
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.jenkinsci.plugins</groupId>
+ <artifactId>multiscm</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>hpi</packaging>
+
+ <!-- get every artifact through maven.glassfish.org, which proxies all the artifacts that we need -->
+ <repositories>
+ <repository>
+ <id>m.g.o-public</id>
+ <url>http://maven.glassfish.org/content/groups/public/</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>m.g.o-public</id>
+ <url>http://maven.glassfish.org/content/groups/public/</url>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
@@ -0,0 +1,181 @@
+package org.jenkinsci.plugins;
+import hudson.Extension;
+import hudson.FilePath;
+import hudson.Launcher;
+import hudson.model.BuildListener;
+import hudson.model.TaskListener;
+import hudson.model.AbstractBuild;
+import hudson.model.AbstractProject;
+import hudson.scm.ChangeLogParser;
+import hudson.scm.PollingResult;
+import hudson.scm.SCMDescriptor;
+import hudson.scm.SCMRevisionState;
+import hudson.scm.NullSCM;
+import hudson.scm.SCM;
+import hudson.tasks.Builder;
+import hudson.util.FormValidation;
+import hudson.util.ListBoxModel;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.ServletException;
+
+import net.sf.json.JSONObject;
+
+import org.kohsuke.stapler.DataBoundConstructor;
+import org.kohsuke.stapler.QueryParameter;
+import org.kohsuke.stapler.StaplerRequest;
+
+/**
+ * Sample {@link Builder}.
+ *
+ * <p>
+ * When the user configures the project and enables this builder,
+ * {@link DescriptorImpl#newInstance(StaplerRequest)} is invoked
+ * and a new {@link MultiSCM} is created. The created
+ * instance is persisted to the project configuration XML by using
+ * XStream, so this allows you to use instance fields (like {@link #name})
+ * to remember the configuration.
+ *
+ * <p>
+ * When a build is performed, the {@link #perform(AbstractBuild, Launcher, BuildListener)} method
+ * will be invoked.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public class MultiSCM extends SCM {
+
+ private final String name;
+
+ // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
+ @DataBoundConstructor
+ public MultiSCM(String name) {
+ this.name = name;
+ }
+
+ /**
+ * We'll use this from the <tt>config.jelly</tt>.
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ @Override
+ public SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?, ?> build,
+ Launcher launcher, TaskListener listener) throws IOException,
+ InterruptedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected PollingResult compareRemoteRevisionWith(
+ AbstractProject<?, ?> project, Launcher launcher,
+ FilePath workspace, TaskListener listener, SCMRevisionState baseline)
+ throws IOException, InterruptedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean checkout(AbstractBuild<?, ?> build, Launcher launcher,
+ FilePath workspace, BuildListener listener, File changelogFile)
+ throws IOException, InterruptedException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public ChangeLogParser createChangeLogParser() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ /**
+ * Descriptor for {@link MultiSCM}. Used as a singleton.
+ * The class is marked as public so that it can be accessed from views.
+ *
+ * <p>
+ * See <tt>views/hudson/plugins/hello_world/HelloWorldBuilder/*.jelly</tt>
+ * for the actual HTML fragment for the configuration screen.
+ */
+ @Extension // this marker indicates Hudson that this is an implementation of an extension point.
+ public static final class DescriptorImpl extends SCMDescriptor<MultiSCM> {
+
+ public DescriptorImpl() {
+ super(MultiSCMRepositoryBrowser.class);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ListBoxModel doFillScmPluginsItems() {
+ ListBoxModel m = new ListBoxModel();
+
+ List<SCMDescriptor<?>> scms = SCM.all();
+
+ for(SCMDescriptor<?> scm : scms) {
+ // Filter MultiSCM itself from the list of choices.
+ // Theoretically it might work, but I see no practical reason to allow
+ // nested MultiSCM configurations.
+ if(!(scm instanceof DescriptorImpl) && !(scm instanceof NullSCM.DescriptorImpl))
+ m.add(scm.getDisplayName());
+ }
+
+ return m;
+ }
+
+ /**
+ * To persist global configuration information,
+ * simply store it in a field and call save().
+ *
+ * <p>
+ * If you don't want fields to be persisted, use <tt>transient</tt>.
+ */
+ private boolean useFrench;
+
+ /**
+ * Performs on-the-fly validation of the form field 'name'.
+ *
+ * @param value
+ * This parameter receives the value that the user has typed.
+ * @return
+ * Indicates the outcome of the validation. This is sent to the browser.
+ */
+ public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException {
+ if(value.length()==0)
+ return FormValidation.error("Please set a name");
+ if(value.length()<4)
+ return FormValidation.warning("Isn't the name too short?");
+ return FormValidation.ok();
+ }
+
+ /**
+ * This human readable name is used in the configuration screen.
+ */
+ public String getDisplayName() {
+ return "Multiple SCMs";
+ }
+
+ @Override
+ public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
+ // To persist global configuration information,
+ // set that to properties and call save().
+ useFrench = formData.getBoolean("useFrench");
+ // ^Can also use req.bindJSON(this, formData);
+ // (easier when there are many fields; need set* methods for this, like setUseFrench)
+ save();
+ return super.configure(req,formData);
+ }
+
+ /**
+ * This method returns true if the global configuration says we should speak French.
+ */
+ public boolean useFrench() {
+ return useFrench;
+ }
+ }
+}
+
@@ -0,0 +1,52 @@
+package org.jenkinsci.plugins;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import hudson.model.AbstractBuild;
+import hudson.model.User;
+import hudson.scm.ChangeLogSet;
+
+import org.jenkinsci.plugins.MultiSCMChangeLogSet.MultiSCMChangeLog;
+
+public class MultiSCMChangeLogSet extends ChangeLogSet<MultiSCMChangeLog> {
+
+ protected MultiSCMChangeLogSet(AbstractBuild<?, ?> build) {
+ super(build);
+ // TODO Auto-generated constructor stub
+ }
+
+ public Iterator<MultiSCMChangeLog> iterator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isEmptySet() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+ public static class MultiSCMChangeLog extends ChangeLogSet.Entry {
+
+ @Override
+ public String getMsg() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public User getAuthor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<String> getAffectedPaths() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+}
@@ -0,0 +1,20 @@
+package org.jenkinsci.plugins;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jenkinsci.plugins.MultiSCMChangeLogSet.MultiSCMChangeLog;
+
+import hudson.scm.RepositoryBrowser;
+
+public class MultiSCMRepositoryBrowser extends RepositoryBrowser<MultiSCMChangeLog> {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public URL getChangeSetLink(MultiSCMChangeLog changeSet) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
@@ -0,0 +1,8 @@
+<!--
+ This view is used to render the plugin list page.
+
+ Since we don't really have anything dynamic here, let's just use static HTML.
+-->
+<div>
+ This plugin is a sample plugin to explain how to write a Hudson plugin.
+</div>
@@ -0,0 +1,29 @@
+<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
+ <!--
+ This jelly script is used for per-project configuration.
+
+ See global.jelly for a general discussion about jelly script.
+ -->
+
+ <!--
+ Creates a text field that shows the value of the "name" property.
+ When submitted, it will be passed to the corresponding constructor parameter.
+ -->
+ <f:entry title="SCMs">
+ <f:repeatable var="loc" name="locations" items="${instance.locations}" >
+ <table width="100%">
+ <f:entry title="SCM Provider"
+ description="Choose the SCM to use"
+ field = "scmPlugins">
+ <!--
+ we'll have on input field. In HTML, single "namespace" is shared between
+ all form components in one <form>, so we need to choose a name that doesn't
+ collide with other plugins. The 'descriptor' variable represents our descriptor
+ object, so we use that to determine the initial value for this form.
+ -->
+ <f:select />
+ </f:entry>
+ </table>
+ </f:repeatable>
+ </f:entry>
+</j:jelly>
@@ -0,0 +1,5 @@
+<div>
+ Help file for fields are discovered through a file name convention. This file is an line help for
+ the "name" field. You can have <i>arbitrary</i> HTML here. You can write this file as a Jelly script
+ if you need a dynamic content (but if you do so, change the extension to .jelly)
+</div>
@@ -0,0 +1,8 @@
+<div>
+ <p>
+ This HTML fragment will be injected into the configuration screen
+ when the user clicks the 'help' icon. See global.jelly for how the
+ form decides which page to load.
+ You can have any HTML fragment here.
+ </p>
+</div>

0 comments on commit f2ee044

Please sign in to comment.