Skip to content

Commit

Permalink
Merge branch 'master' into JENKINS-18048
Browse files Browse the repository at this point in the history
Conflicts:
	core/src/main/java/hudson/triggers/SCMTrigger.java
  • Loading branch information
daniel-beck committed Jun 28, 2014
2 parents e937b09 + 0bfab57 commit 8ec206f
Show file tree
Hide file tree
Showing 223 changed files with 4,878 additions and 5,873 deletions.
14 changes: 10 additions & 4 deletions BUILDING.TXT
@@ -1,6 +1,12 @@
If you want simply to have the jenkins.war as fast as possible (without test execution), just use :
mvn clean install -pl war -am -DskipTests
the war will be in war/target/jenkins.war (you can play with it)
If you want simply to have the jenkins.war as fast as possible (without test
execution), run:

mvn clean install -pl war -am -DskipTests

The WAR file will be in war/target/jenkins.war (you can play with it)
You can deactivate test-harness execution with -Dskip-test-harness
Have Fun !!

For more information on building Jenkins, visit
https://wiki.jenkins-ci.org/display/JENKINS/Building+Jenkins

Have Fun !!
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@ Copyright © 2004–, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a number of

About
-----
In a nutshell Jenkins CI is the leading open-source continuous integration server. Built with Java, it provides over 300 plugins to support building and testing virtually any project.
In a nutshell Jenkins CI is the leading open-source continuous integration server. Built with Java, it provides over 930 plugins to support building and testing virtually any project.

Downloads
---------
Expand Down
4,912 changes: 204 additions & 4,708 deletions changelog.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cli/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pom</artifactId>
<groupId>org.jenkins-ci.main</groupId>
<version>1.564-SNAPSHOT</version>
<version>1.571-SNAPSHOT</version>
</parent>

<artifactId>cli</artifactId>
Expand Down
10 changes: 5 additions & 5 deletions core/pom.xml
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>pom</artifactId>
<version>1.564-SNAPSHOT</version>
<version>1.571-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -42,7 +42,7 @@ THE SOFTWARE.

<properties>
<staplerFork>true</staplerFork>
<stapler.version>1.224</stapler.version>
<stapler.version>1.227</stapler.version>
<spring.version>2.5.6.SEC03</spring.version>
<groovy.version>1.8.9</groovy.version>
</properties>
Expand Down Expand Up @@ -112,7 +112,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>trilead-ssh2</artifactId>
<version>build217-jenkins-3</version>
<version>build217-jenkins-5</version>
</dependency>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
Expand Down Expand Up @@ -479,12 +479,12 @@ THE SOFTWARE.
<dependency>
<groupId>org.jvnet.winp</groupId>
<artifactId>winp</artifactId>
<version>1.19</version>
<version>1.20</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>memory-monitor</artifactId>
<version>1.7</version>
<version>1.8</version>
</dependency>
<dependency><!-- StAX implementation. See HUDSON-2547. -->
<groupId>org.codehaus.woodstox</groupId>
Expand Down
40 changes: 32 additions & 8 deletions core/src/main/java/hudson/ClassicPluginStrategy.java
Expand Up @@ -66,6 +66,7 @@
import java.util.List;
import java.util.Vector;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -92,15 +93,26 @@ public ClassicPluginStrategy(PluginManager pluginManager) {
this.pluginManager = pluginManager;
}

public PluginWrapper createPluginWrapper(File archive) throws IOException {
final Manifest manifest;
URL baseResourceURL;
@Override public String getShortName(File archive) throws IOException {
Manifest manifest;
if (isLinked(archive)) {
manifest = loadLinkedManifest(archive);
} else {
JarFile jf = new JarFile(archive, false);
try {
manifest = jf.getManifest();
} finally {
jf.close();
}
}
return PluginWrapper.computeShortName(manifest, archive);
}

File expandDir = null;
// if .hpi, this is the directory where war is expanded
private static boolean isLinked(File archive) {
return archive.getName().endsWith(".hpl") || archive.getName().endsWith(".jpl");
}

boolean isLinked = archive.getName().endsWith(".hpl") || archive.getName().endsWith(".jpl");
if (isLinked) {
private static Manifest loadLinkedManifest(File archive) throws IOException {
// resolve the .hpl file to the location of the manifest file
final String firstLine = IOUtils.readFirstLine(new FileInputStream(archive), "UTF-8");
if (firstLine.startsWith("Manifest-Version:")) {
Expand All @@ -112,12 +124,24 @@ public PluginWrapper createPluginWrapper(File archive) throws IOException {
// then parse manifest
FileInputStream in = new FileInputStream(archive);
try {
manifest = new Manifest(in);
return new Manifest(in);
} catch (IOException e) {
throw new IOException("Failed to load " + archive, e);
} finally {
in.close();
}
}

@Override public PluginWrapper createPluginWrapper(File archive) throws IOException {
final Manifest manifest;
URL baseResourceURL;

File expandDir = null;
// if .hpi, this is the directory where war is expanded

boolean isLinked = isLinked(archive);
if (isLinked) {
manifest = loadLinkedManifest(archive);
} else {
if (archive.isDirectory()) {// already expanded
expandDir = archive;
Expand Down
18 changes: 18 additions & 0 deletions core/src/main/java/hudson/FilePath.java
Expand Up @@ -30,6 +30,7 @@
import hudson.Launcher.LocalLauncher;
import hudson.Launcher.RemoteLauncher;
import hudson.model.AbstractProject;
import hudson.model.Computer;
import hudson.model.Item;
import hudson.model.TaskListener;
import hudson.org.apache.tools.tar.TarInputStream;
Expand Down Expand Up @@ -69,6 +70,7 @@
import org.apache.tools.zip.ZipFile;
import org.kohsuke.stapler.Stapler;

import javax.annotation.CheckForNull;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileFilter;
Expand Down Expand Up @@ -1056,6 +1058,22 @@ public VirtualFile toVirtualFile() {
return VirtualFile.forFilePath(this);
}

/**
* If this {@link FilePath} represents a file on a particular {@link Computer}, return it.
* Otherwise null.
*/
public @CheckForNull Computer toComputer() {
Jenkins j = Jenkins.getInstance();
if (j != null) {
for (Computer c : j.getComputers()) {
if (getChannel()==c.getChannel()) {
return c;
}
}
}
return null;
}

/**
* Creates this directory.
*/
Expand Down
89 changes: 88 additions & 1 deletion core/src/main/java/hudson/Launcher.java
Expand Up @@ -300,8 +300,13 @@ public ProcStarter envs(String... overrides) {
return this;
}

/**
* Gets a list of environment variables to be set.
* Returns an empty array if envs field has not been initialized.
* @return If initialized, returns a copy of internal envs array. Otherwise - a new empty array.
*/
public String[] envs() {
return envs.clone();
return envs != null ? envs.clone() : new String[0];
}

/**
Expand Down Expand Up @@ -972,6 +977,88 @@ public OutputStream getStdin() {
}
}
}

/**
* A launcher which delegates to a provided inner launcher.
* Allows subclasses to only implement methods they want to override.
* Originally, this launcher has been implemented in
* <a href="https://wiki.jenkins-ci.org/display/JENKINS/Custom+Tools+Plugin">
* Custom Tools Plugin</a>.
*
* @author rcampbell
* @author Oleg Nenashev, Synopsys Inc.
* @since TODO: define version
*/
public static class DecoratedLauncher extends Launcher {

private Launcher inner = null;

public DecoratedLauncher(Launcher inner) {
super(inner);
this.inner = inner;
}

@Override
public Proc launch(ProcStarter starter) throws IOException {
return inner.launch(starter);
}

@Override
public Channel launchChannel(String[] cmd, OutputStream out,
FilePath workDir, Map<String, String> envVars) throws IOException,
InterruptedException {
return inner.launchChannel(cmd, out, workDir, envVars);
}

@Override
public void kill(Map<String, String> modelEnvVars) throws IOException,
InterruptedException {
inner.kill(modelEnvVars);
}

@Override
public boolean isUnix() {
return inner.isUnix();
}

@Override
public Proc launch(String[] cmd, boolean[] mask, String[] env, InputStream in, OutputStream out, FilePath workDir) throws IOException {
return inner.launch(cmd, mask, env, in, out, workDir);
}

@Override
public Computer getComputer() {
return inner.getComputer();
}

@Override
public TaskListener getListener() {
return inner.getListener();
}

@Override
public String toString() {
return super.toString() + "; decorates " + inner.toString();
}

@Override
public VirtualChannel getChannel() {
return inner.getChannel();
}

@Override
public Proc launch(String[] cmd, String[] env, InputStream in, OutputStream out, FilePath workDir) throws IOException {
return inner.launch(cmd, env, in, out, workDir);
}

/**
* Gets nested launcher.
* @return Inner launcher
*/
public Launcher getInner() {
return inner;
}
}

public static class IOTriplet implements Serializable {
InputStream stdout,stderr;
Expand Down
23 changes: 18 additions & 5 deletions core/src/main/java/hudson/PluginManager.java
Expand Up @@ -412,11 +412,21 @@ private boolean containsHpiJpi(Collection<String> bundledPlugins, String name) {
*/
public void dynamicLoad(File arc) throws IOException, InterruptedException, RestartRequiredException {
LOGGER.info("Attempting to dynamic load "+arc);
final PluginWrapper p = strategy.createPluginWrapper(arc);
String sn = p.getShortName();
PluginWrapper p = null;
String sn;
try {
sn = strategy.getShortName(arc);
} catch (AbstractMethodError x) {
LOGGER.log(WARNING, "JENKINS-12753 fix not active: {0}", x.getMessage());
p = strategy.createPluginWrapper(arc);
sn = p.getShortName();
}
if (getPlugin(sn)!=null)
throw new RestartRequiredException(Messages._PluginManager_PluginIsAlreadyInstalled_RestartRequired(sn));

if (p == null) {
p = strategy.createPluginWrapper(arc);
}
if (p.supportsDynamicLoad()== YesNoMaybe.NO)
throw new RestartRequiredException(Messages._PluginManager_PluginDoesntSupportDynamicLoad_RestartRequired(sn));

Expand All @@ -442,10 +452,11 @@ public void dynamicLoad(File arc) throws IOException, InterruptedException, Rest

// run initializers in the added plugin
Reactor r = new Reactor(InitMilestone.ordering());
r.addAll(new InitializerFinder(p.classLoader) {
final ClassLoader loader = p.classLoader;
r.addAll(new InitializerFinder(loader) {
@Override
protected boolean filter(Method e) {
return e.getDeclaringClass().getClassLoader()!=p.classLoader || super.filter(e);
return e.getDeclaringClass().getClassLoader() != loader || super.filter(e);
}
}.discoverTasks(r));
try {
Expand Down Expand Up @@ -721,7 +732,9 @@ public void doInstall(StaplerRequest req, StaplerResponse rsp) throws IOExceptio
String pluginName = n.substring(0, index);
String siteName = n.substring(index + 1);
UpdateSite updateSite = Jenkins.getInstance().getUpdateCenter().getById(siteName);
if (siteName != null) {
if (updateSite == null) {
throw new Failure("No such update center: " + siteName);
} else {
UpdateSite.Plugin plugin = updateSite.getPlugin(pluginName);
if (plugin != null) {
if (p != null) {
Expand Down
10 changes: 8 additions & 2 deletions core/src/main/java/hudson/PluginStrategy.java
Expand Up @@ -24,11 +24,10 @@
package hudson;

import hudson.model.Hudson;
import jenkins.model.Jenkins;

import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nonnull;

/**
* Pluggability point for how to create {@link PluginWrapper}.
Expand All @@ -50,6 +49,13 @@ public interface PluginStrategy extends ExtensionPoint {
PluginWrapper createPluginWrapper(File archive)
throws IOException;

/**
* Finds the plugin name without actually unpacking anything {@link #createPluginWrapper} would.
* Needed by {@link PluginManager#dynamicLoad} to decide whether such a plugin is already installed.
* @return the {@link PluginWrapper#getShortName}
*/
@Nonnull String getShortName(File archive) throws IOException;

/**
* Loads the plugin and starts it.
*
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/PluginWrapper.java
Expand Up @@ -238,7 +238,7 @@ public URL getIndexPage() {
return idx != null && idx.toString().contains(shortName) ? idx : null;
}

private String computeShortName(Manifest manifest, File archive) {
static String computeShortName(Manifest manifest, File archive) {
// use the name captured in the manifest, as often plugins
// depend on the specific short name in its URLs.
String n = manifest.getMainAttributes().getValue("Short-Name");
Expand Down

0 comments on commit 8ec206f

Please sign in to comment.