diff --git a/cli/pom.xml b/cli/pom.xml
index 2237c4a533..01b2dc12af 100644
--- a/cli/pom.xml
+++ b/cli/pom.xml
@@ -5,7 +5,7 @@
pom
org.jenkins-ci.main
- 1.581-SNAPSHOT
+ 1.582-SNAPSHOT
cli
diff --git a/core/pom.xml b/core/pom.xml
index 75c4479489..738ee7ba86 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -29,7 +29,7 @@ THE SOFTWARE.
org.jenkins-ci.main
pom
- 1.581-SNAPSHOT
+ 1.582-SNAPSHOT
../pom.xml
diff --git a/core/src/main/java/hudson/Plugin.java b/core/src/main/java/hudson/Plugin.java
index 69c6118d12..1e11d23bcd 100644
--- a/core/src/main/java/hudson/Plugin.java
+++ b/core/src/main/java/hudson/Plugin.java
@@ -48,7 +48,10 @@ import org.kohsuke.stapler.HttpResponses;
* Base class of Hudson plugin.
*
*
- * A plugin needs to derive from this class.
+ * A plugin may derive from this class, or it may directly define extension
+ * points annotated with {@link hudson.Extension}. For a list of extension
+ * points, see
+ * https://wiki.jenkins-ci.org/display/JENKINS/Extension+points.
*
*
* One instance of a plugin is created by Hudson, and used as the entry point
diff --git a/core/src/main/java/hudson/model/LoadStatistics.java b/core/src/main/java/hudson/model/LoadStatistics.java
index 81ebae78de..b996f040b4 100644
--- a/core/src/main/java/hudson/model/LoadStatistics.java
+++ b/core/src/main/java/hudson/model/LoadStatistics.java
@@ -233,7 +233,7 @@ public abstract class LoadStatistics {
int q=0;
for (Queue.BuildableItem bi : bis) {
for (SubTask st : Tasks.getSubTasksOf(bi.task))
- if (st.getAssignedLabel()==l)
+ if (bi.getAssignedLabelFor(st)==l)
q++;
}
return q;
diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java
index 830eb851f6..da478515f4 100644
--- a/core/src/main/java/hudson/model/Queue.java
+++ b/core/src/main/java/hudson/model/Queue.java
@@ -834,11 +834,11 @@ public class Queue extends ResourceController implements Saveable {
int r = 0;
for (BuildableItem bi : buildables.values())
for (SubTask st : bi.task.getSubTasks())
- if (null==l || st.getAssignedLabel()==l)
+ if (null==l || bi.getAssignedLabelFor(st)==l)
r++;
for (BuildableItem bi : pendings.values())
for (SubTask st : bi.task.getSubTasks())
- if (null==l || st.getAssignedLabel()==l)
+ if (null==l || bi.getAssignedLabelFor(st)==l)
r++;
return r;
}
@@ -1414,6 +1414,21 @@ public class Queue extends ResourceController implements Saveable {
}
return task.getAssignedLabel();
}
+
+ /**
+ * Test if the specified {@link SubTask} needs to be run on a node with a particular label, and
+ * return that {@link Label}. Otherwise null, indicating it can run on anywhere.
+ *
+ *
+ * This code takes {@link LabelAssignmentAction} into account, then falls back to {@link SubTask#getAssignedLabel()}
+ */
+ public Label getAssignedLabelFor(SubTask st) {
+ for (LabelAssignmentAction laa : getActions(LabelAssignmentAction.class)) {
+ Label l = laa.getAssignedLabel(st);
+ if (l!=null) return l;
+ }
+ return st.getAssignedLabel();
+ }
/**
* Convenience method that returns a read only view of the {@link Cause}s associated with this item in the queue.
diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java
index 625cea4b05..0393914e12 100644
--- a/core/src/main/java/hudson/model/Slave.java
+++ b/core/src/main/java/hudson/model/Slave.java
@@ -208,6 +208,10 @@ public abstract class Slave extends Node implements Serializable {
return name;
}
+ @Override public String toString() {
+ return getClass().getName() + "[" + name + "]";
+ }
+
public void setNodeName(String name) {
this.name = name;
}
diff --git a/core/src/main/java/hudson/model/labels/LabelAtomProperty.java b/core/src/main/java/hudson/model/labels/LabelAtomProperty.java
index e0dfd53259..efaad2ab77 100644
--- a/core/src/main/java/hudson/model/labels/LabelAtomProperty.java
+++ b/core/src/main/java/hudson/model/labels/LabelAtomProperty.java
@@ -42,6 +42,7 @@ import java.util.Collections;
* with the {@link LabelAtom} object.
*
* @author Kohsuke Kawaguchi
+ * @see hudson.model.labels.LabelAtomPropertyDescriptor
* @since 1.373
*/
@ExportedBean
diff --git a/core/src/main/java/hudson/model/labels/LabelAtomPropertyDescriptor.java b/core/src/main/java/hudson/model/labels/LabelAtomPropertyDescriptor.java
index 43724c73c4..82312097dc 100644
--- a/core/src/main/java/hudson/model/labels/LabelAtomPropertyDescriptor.java
+++ b/core/src/main/java/hudson/model/labels/LabelAtomPropertyDescriptor.java
@@ -31,6 +31,11 @@ import hudson.model.Descriptor;
*
*
* Put {@link Extension} on your descriptor implementation to have it auto-registered.
+ *
+ *
+ * When extending this class, override Descriptor.getDisplayName(). In the
+ * context of LabelAtomPropertyDescriptor, this function is used to determine the label of
+ * the checkbox shown in the label's configuration page to activate the extension.
*
* @author Kohsuke Kawaguchi
* @since 1.373
diff --git a/core/src/main/java/hudson/tasks/BatchFile.java b/core/src/main/java/hudson/tasks/BatchFile.java
index 0943e9147f..b2506474be 100644
--- a/core/src/main/java/hudson/tasks/BatchFile.java
+++ b/core/src/main/java/hudson/tasks/BatchFile.java
@@ -26,9 +26,11 @@ package hudson.tasks;
import hudson.FilePath;
import hudson.Extension;
import hudson.model.AbstractProject;
+import hudson.util.LineEndingConversion;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
+import java.io.ObjectStreamException;
/**
* Executes commands by using Windows batch file.
@@ -38,7 +40,7 @@ import org.kohsuke.stapler.StaplerRequest;
public class BatchFile extends CommandInterpreter {
@DataBoundConstructor
public BatchFile(String command) {
- super(command);
+ super(LineEndingConversion.convertEOL(command, LineEndingConversion.EOLType.Windows));
}
public String[] buildCommandLine(FilePath script) {
@@ -46,13 +48,17 @@ public class BatchFile extends CommandInterpreter {
}
protected String getContents() {
- return command+"\r\nexit %ERRORLEVEL%";
+ return LineEndingConversion.convertEOL(command+"\r\nexit %ERRORLEVEL%",LineEndingConversion.EOLType.Windows);
}
protected String getFileExtension() {
return ".bat";
}
+ private Object readResolve() throws ObjectStreamException {
+ return new BatchFile(command);
+ }
+
@Extension
public static final class DescriptorImpl extends BuildStepDescriptor {
@Override
diff --git a/core/src/main/java/hudson/tasks/Shell.java b/core/src/main/java/hudson/tasks/Shell.java
index 5a3a2053db..17ce0b8819 100644
--- a/core/src/main/java/hudson/tasks/Shell.java
+++ b/core/src/main/java/hudson/tasks/Shell.java
@@ -32,6 +32,8 @@ import hudson.remoting.Callable;
import hudson.remoting.VirtualChannel;
import hudson.util.FormValidation;
import java.io.IOException;
+import java.io.ObjectStreamException;
+import hudson.util.LineEndingConversion;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
@@ -50,29 +52,7 @@ import java.util.logging.Logger;
public class Shell extends CommandInterpreter {
@DataBoundConstructor
public Shell(String command) {
- super(fixCrLf(command));
- }
-
- /**
- * Fix CR/LF and always make it Unix style.
- */
- private static String fixCrLf(String s) {
- // eliminate CR
- int idx;
- while((idx=s.indexOf("\r\n"))!=-1)
- s = s.substring(0,idx)+s.substring(idx+1);
-
- //// add CR back if this is for Windows
- //if(isWindows()) {
- // idx=0;
- // while(true) {
- // idx = s.indexOf('\n',idx);
- // if(idx==-1) break;
- // s = s.substring(0,idx)+'\r'+s.substring(idx);
- // idx+=2;
- // }
- //}
- return s;
+ super(LineEndingConversion.convertEOL(command, LineEndingConversion.EOLType.Unix));
}
/**
@@ -80,7 +60,7 @@ public class Shell extends CommandInterpreter {
* makes the shell think the file is a binary file and not a script. Adding
* a leading line feed works around this problem.
*/
- private static String addCrForNonASCII(String s) {
+ private static String addLineFeedForNonASCII(String s) {
if(!s.startsWith("#!")) {
if (s.indexOf('\n')!=0) {
return "\n" + s;
@@ -105,7 +85,7 @@ public class Shell extends CommandInterpreter {
}
protected String getContents() {
- return addCrForNonASCII(fixCrLf(command));
+ return addLineFeedForNonASCII(LineEndingConversion.convertEOL(command,LineEndingConversion.EOLType.Unix));
}
protected String getFileExtension() {
@@ -117,6 +97,10 @@ public class Shell extends CommandInterpreter {
return (DescriptorImpl)super.getDescriptor();
}
+ private Object readResolve() throws ObjectStreamException {
+ return new Shell(command);
+ }
+
@Extension
public static class DescriptorImpl extends BuildStepDescriptor {
/**
diff --git a/core/src/main/java/hudson/tools/AbstractCommandInstaller.java b/core/src/main/java/hudson/tools/AbstractCommandInstaller.java
index 07d91c6c0c..18431fcda1 100644
--- a/core/src/main/java/hudson/tools/AbstractCommandInstaller.java
+++ b/core/src/main/java/hudson/tools/AbstractCommandInstaller.java
@@ -48,7 +48,7 @@ public abstract class AbstractCommandInstaller extends ToolInstaller {
public AbstractCommandInstaller(String label, String command, String toolHome) {
super(label);
- this.command = fixCrLf(command);
+ this.command = command;
this.toolHome = toolHome;
}
@@ -84,19 +84,6 @@ public abstract class AbstractCommandInstaller extends ToolInstaller {
return dir.child(getToolHome());
}
- /**
- * Fix CR/LF and always make it Unix style.
- */
- //TODO: replace by a Windows style
- private static String fixCrLf(String s) {
- // eliminate CR
- int idx;
- while ((idx = s.indexOf("\r\n")) != -1) {
- s = s.substring(0, idx) + s.substring(idx + 1);
- }
- return s;
- }
-
public static abstract class Descriptor
extends ToolInstallerDescriptor {
diff --git a/core/src/main/java/hudson/tools/BatchCommandInstaller.java b/core/src/main/java/hudson/tools/BatchCommandInstaller.java
index 415dbb700f..2085fe7fa0 100644
--- a/core/src/main/java/hudson/tools/BatchCommandInstaller.java
+++ b/core/src/main/java/hudson/tools/BatchCommandInstaller.java
@@ -26,7 +26,9 @@ package hudson.tools;
import hudson.Extension;
import hudson.FilePath;
+import hudson.util.LineEndingConversion;
import org.kohsuke.stapler.DataBoundConstructor;
+import java.io.ObjectStreamException;
/**
* Installs tool via script execution of Batch script.
@@ -37,7 +39,7 @@ public class BatchCommandInstaller extends AbstractCommandInstaller {
@DataBoundConstructor
public BatchCommandInstaller(String label, String command, String toolHome) {
- super(label, command, toolHome);
+ super(label, LineEndingConversion.convertEOL(command, LineEndingConversion.EOLType.Windows), toolHome);
}
@Override
@@ -50,6 +52,10 @@ public class BatchCommandInstaller extends AbstractCommandInstaller {
String[] cmd = {"cmd", "/c", "call", script.getRemote()};
return cmd;
}
+
+ private Object readResolve() throws ObjectStreamException {
+ return new BatchCommandInstaller(getLabel(), getCommand(), getToolHome());
+ }
@Extension
public static class DescriptorImpl extends Descriptor {
diff --git a/core/src/main/java/hudson/tools/CommandInstaller.java b/core/src/main/java/hudson/tools/CommandInstaller.java
index b02137f0f5..6f2506dd04 100644
--- a/core/src/main/java/hudson/tools/CommandInstaller.java
+++ b/core/src/main/java/hudson/tools/CommandInstaller.java
@@ -26,7 +26,9 @@ package hudson.tools;
import hudson.Extension;
import hudson.FilePath;
+import hudson.util.LineEndingConversion;
import org.kohsuke.stapler.DataBoundConstructor;
+import java.io.ObjectStreamException;
/**
* Installs a tool by running an arbitrary shell command.
@@ -36,7 +38,7 @@ public class CommandInstaller extends AbstractCommandInstaller {
@DataBoundConstructor
public CommandInstaller(String label, String command, String toolHome) {
- super(label, command, toolHome);
+ super(label, LineEndingConversion.convertEOL(command, LineEndingConversion.EOLType.Unix), toolHome);
}
@Override
@@ -50,6 +52,10 @@ public class CommandInstaller extends AbstractCommandInstaller {
return cmd;
}
+ private Object readResolve() throws ObjectStreamException {
+ return new CommandInstaller(getLabel(), getCommand(), getToolHome());
+ }
+
@Extension
public static class DescriptorImpl extends Descriptor {
diff --git a/core/src/main/java/hudson/util/LineEndingConversion.java b/core/src/main/java/hudson/util/LineEndingConversion.java
new file mode 100644
index 0000000000..744ff4a4ea
--- /dev/null
+++ b/core/src/main/java/hudson/util/LineEndingConversion.java
@@ -0,0 +1,66 @@
+package hudson.util;
+
+/**
+ * Converts line endings of a string.
+ *
+ * @since TODO
+ * @author David Ruhmann
+ */
+public class LineEndingConversion {
+
+ /**
+ * Supported line ending types for conversion
+ */
+ public enum EOLType {
+ CR,
+ CRLF,
+ LF,
+ LFCR,
+ Mac,
+ Unix,
+ Windows
+ }
+
+ /**
+ * Convert line endings of a string to the given type. Default to Unix type.
+ *
+ * @param input
+ * The string containing line endings to be converted.
+ * @param type
+ * Type of line endings to convert the string into.
+ * @return
+ * String updated with the new line endings or null if given null.
+ */
+ public static String convertEOL(String input, EOLType type) {
+ if (null == input || 0 == input.length()) {
+ return input;
+ }
+ // Convert line endings to Unix LF,
+ // which also sets up the string for other conversions
+ input = input.replace("\r\n","\n");
+ input = input.replace("\r","\n");
+ switch (type) {
+ case CR:
+ case Mac:
+ // Convert line endings to CR
+ input = input.replace("\n", "\r");
+ break;
+ case CRLF:
+ case Windows:
+ // Convert line endings to Windows CR/LF
+ input = input.replace("\n", "\r\n");
+ break;
+ default:
+ case LF:
+ case Unix:
+ // Conversion already completed
+ return input;
+ case LFCR:
+ // Convert line endings to LF/CR
+ input = input.replace("\n", "\n\r");
+ break;
+ }
+ return input;
+ }
+}
+
diff --git a/core/src/main/java/jenkins/model/GlobalConfiguration.java b/core/src/main/java/jenkins/model/GlobalConfiguration.java
index b6e873f952..92eabc4ea7 100644
--- a/core/src/main/java/jenkins/model/GlobalConfiguration.java
+++ b/core/src/main/java/jenkins/model/GlobalConfiguration.java
@@ -6,17 +6,28 @@ import hudson.model.Describable;
import hudson.model.Descriptor;
/**
- * Convenient base class for extensions that contributes to the system configuration page but nothing else.
+ * Convenient base class for extensions that contributes to the system configuration page but nothing
+ * else, or to manage the global configuration of a plugin implementing several extension points.
*
*
- * All {@link Descriptor}s are capable of contributing fragment to the system config page, so
- * this extension point is is really only for those who don't want to contribute anything else.
- * If you are implementing other extension points and that would like to expose some global configuration,
- * you can do so with global.groovy from your {@link Descriptor} instance.
+ * All {@link Descriptor}s are capable of contributing fragment to the system config page. If you are
+ * implementing other extension points that need to expose some global configuration, you can do so
+ * with global.groovy or global.jelly from your {@link Descriptor} instance. However
+ * each global.* file will appear as its own section in the global configuration page.
+ *
+ *
+ * An option to present a single section for your plugin in the Jenkins global configuration page is
+ * to use this class to manage the configuration for your plugin and its extension points. To access
+ * properties defined in your GlobalConfiguration subclass, here are two possibilities:
+ *
- @{@link javax.inject.Inject} into your other {@link hudson.Extension}s (so this does not work
+ * for classes not annotated with {@link hudson.Extension})
+ * - access it via a call to
GlobalConfiguration.all().get(<your GlobalConfiguration subclass>.class)
+ *
*
* Views
*
- * Subtypes of this class should define config.groovy that gets pulled into the system configuration page.
+ * Subtypes of this class should define a config.groovy file or config.jelly file
+ * that gets pulled into the system configuration page.
*
*
* @author Kohsuke Kawaguchi
diff --git a/core/src/main/resources/lib/form/descriptorList.jelly b/core/src/main/resources/lib/form/descriptorList.jelly
index 54973dc403..23db231665 100644
--- a/core/src/main/resources/lib/form/descriptorList.jelly
+++ b/core/src/main/resources/lib/form/descriptorList.jelly
@@ -39,7 +39,7 @@ THE SOFTWARE.
method works fine, too, such as DescribableList.
- Either @field or @instances are required (or @field needs to be inherited from the ancestor <entry> elemetn.
+ Either @field or @instances are required (or @field may be inherited from the ancestor <entry> element).
If field is specified, instances are assumed to be instance[field].
When this attribute is specified, JSON structure is properly set up so that the databinding
@@ -86,4 +86,4 @@ THE SOFTWARE.
-
\ No newline at end of file
+
diff --git a/debian/debian/changelog b/debian/debian/changelog
index d964ffbcbd..318c8f2af8 100644
--- a/debian/debian/changelog
+++ b/debian/debian/changelog
@@ -1,3 +1,9 @@
+jenkins (1.581) unstable; urgency=low
+
+ * See http://jenkins-ci.org/changelog for more details.
+
+ -- Kohsuke Kawaguchi Sun, 21 Sep 2014 21:52:50 -0700
+
jenkins (1.580) unstable; urgency=low
* See http://jenkins-ci.org/changelog for more details.
diff --git a/debian/debian/jenkins.init b/debian/debian/jenkins.init
index 8d10398358..669b4f39d2 100644
--- a/debian/debian/jenkins.init
+++ b/debian/debian/jenkins.init
@@ -23,7 +23,11 @@ SCRIPTNAME=/etc/init.d/$NAME
#DAEMON=$JENKINS_SH
DAEMON=/usr/bin/daemon
-DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=$JENKINS_HOME --output=$JENKINS_LOG --pidfile=$PIDFILE"
+DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=$JENKINS_HOME --output=$JENKINS_LOG --pidfile=$PIDFILE"
+
+if [ -n "$UMASK" ]; then
+ DAEMON_ARGS="$DAEMON_ARGS --umask=$UMASK"
+fi
SU=/bin/su
@@ -108,10 +112,9 @@ do_start()
ulimit -n $MAXOPENFILES
fi
- # honor umask setting
+ # notify of explicit umask
if [ -n "$UMASK" ]; then
[ "$VERBOSE" != no ] && echo Setting umask to $UMASK
- umask $UMASK
fi
# --user in daemon doesn't prepare environment variables like HOME, USER, LOGNAME or USERNAME,
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 043dda4b07..1ad16ab63d 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -11,7 +11,7 @@
org.jenkins-ci.plugins
plugin
Jenkins plugin POM
- 1.581-SNAPSHOT
+ 1.582-SNAPSHOT
pom
org.jenkins-ci
winstone
- 2.3
+ 2.4
test
@@ -119,7 +119,7 @@ THE SOFTWARE.
org.jenkins-ci.modules
slave-installer
- 1.3
+ 1.5
org.jenkins-ci.modules
@@ -340,7 +340,7 @@ THE SOFTWARE.
org.jenkins-ci.plugins
mailer
- 1.10
+ 1.11
hpi