mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
Merge remote-tracking branch 'origin/master' into executor-ondemand
This commit is contained in:
commit
8c4288ca59
789 files changed
+2568
-52314
No files matched your search
@@ -107,6 +107,7 @@ public class CLICommandInvoker {
|
||||
|
||||
GlobalMatrixAuthorizationStrategy auth = new GlobalMatrixAuthorizationStrategy();
|
||||
for(Permission p: permissions) {
|
||||
p.setEnabled(true);
|
||||
auth.add(p, username);
|
||||
}
|
||||
rule.jenkins.setAuthorizationStrategy(auth);
|
||||
|
||||
@@ -15,7 +15,9 @@ import java.io.IOException;
|
||||
* {@link HudsonTestCase} with more convenience methods for Groovy.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @deprecated Use {@link GroovyJenkinsRule} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class GroovyHudsonTestCase extends HudsonTestCase {
|
||||
/**
|
||||
* Executes the given closure on the server, in the context of an HTTP request.
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2013 Jesse Glick.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.jvnet.hudson.test;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
import hudson.Launcher;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.tasks.Builder;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
/**
|
||||
* {@link JenkinsRule} variant with special options for tests written in Groovy.
|
||||
* @since 1.535
|
||||
*/
|
||||
public class GroovyJenkinsRule extends JenkinsRule {
|
||||
|
||||
/**
|
||||
* Executes the given closure on the server, in the context of an HTTP request.
|
||||
* This is useful for testing some methods that require {@link StaplerRequest} and {@link StaplerResponse}.
|
||||
*
|
||||
* <p>
|
||||
* The closure will get the request and response as parameters.
|
||||
*/
|
||||
public Object executeOnServer(final Closure c) throws Exception {
|
||||
return executeOnServer(new Callable<Object>() {
|
||||
@Override public Object call() throws Exception {
|
||||
return c.call();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps a closure as a {@link Builder}.
|
||||
*/
|
||||
public Builder builder(final Closure c) {
|
||||
return new TestBuilder() {
|
||||
@Override public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
|
||||
Object r = c.call(new Object[] {build, launcher, listener});
|
||||
if (r instanceof Boolean) {
|
||||
return (Boolean) r;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,6 +57,7 @@ import hudson.model.*;
|
||||
import hudson.model.Executor;
|
||||
import hudson.model.Node.Mode;
|
||||
import hudson.model.Queue.Executable;
|
||||
import hudson.os.PosixAPI;
|
||||
import hudson.remoting.Which;
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.AbstractPasswordBasedSecurityRealm;
|
||||
@@ -82,7 +83,6 @@ import hudson.tools.ToolProperty;
|
||||
import hudson.util.PersistedList;
|
||||
import hudson.util.ReflectionUtils;
|
||||
import hudson.util.StreamTaskListener;
|
||||
import hudson.util.jna.GNUCLibrary;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.io.BufferedReader;
|
||||
@@ -587,8 +587,9 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
|
||||
mvn.copyFrom(HudsonTestCase.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
|
||||
mvn.unzip(new FilePath(buildDirectory));
|
||||
// TODO: switch to tar that preserves file permissions more easily
|
||||
if(!Functions.isWindows())
|
||||
GNUCLibrary.LIBC.chmod(new File(mvnHome, "bin/mvn").getPath(),0755);
|
||||
if(!Functions.isWindows()) {
|
||||
PosixAPI.jnr().chmod(new File(mvnHome, "bin/mvn").getPath(), 0755);
|
||||
}
|
||||
|
||||
MavenInstallation mavenInstallation = new MavenInstallation("default",
|
||||
mvnHome.getAbsolutePath(), NO_PROPERTIES);
|
||||
@@ -611,8 +612,9 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
|
||||
File antHome = createTmpDir();
|
||||
ant.unzip(new FilePath(antHome));
|
||||
// TODO: switch to tar that preserves file permissions more easily
|
||||
if(!Functions.isWindows())
|
||||
GNUCLibrary.LIBC.chmod(new File(antHome,"apache-ant-1.8.1/bin/ant").getPath(),0755);
|
||||
if(!Functions.isWindows()) {
|
||||
PosixAPI.jnr().chmod(new File(antHome,"apache-ant-1.8.1/bin/ant").getPath(),0755);
|
||||
}
|
||||
|
||||
antInstallation = new AntInstallation("default", new File(antHome,"apache-ant-1.8.1").getAbsolutePath(),NO_PROPERTIES);
|
||||
}
|
||||
@@ -1976,8 +1978,8 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
|
||||
|
||||
if (!Functions.isWindows()) {
|
||||
try {
|
||||
GNUCLibrary.LIBC.unsetenv("MAVEN_OPTS");
|
||||
GNUCLibrary.LIBC.unsetenv("MAVEN_DEBUG_OPTS");
|
||||
PosixAPI.jnr().unsetenv("MAVEN_OPTS");
|
||||
PosixAPI.jnr().unsetenv("MAVEN_DEBUG_OPTS");
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.WARNING,"Failed to cancel out MAVEN_OPTS",e);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,6 @@ import java.util.logging.Logger;
|
||||
import jenkins.model.JenkinsLocationConfiguration;
|
||||
|
||||
import org.acegisecurity.GrantedAuthorityImpl;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
|
||||
import static org.hamcrest.Matchers.hasXPath;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@@ -1537,10 +1536,22 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
|
||||
.createEmbedder(new StreamTaskListener(System.out, Charset.defaultCharset()),
|
||||
(File) null, null);
|
||||
for( String dep : dependencies.split(",")) {
|
||||
String suffix = ";resolution:=optional";
|
||||
boolean optional = dep.endsWith(suffix);
|
||||
if (optional) {
|
||||
dep = dep.substring(0, dep.length() - suffix.length());
|
||||
}
|
||||
String[] tokens = dep.split(":");
|
||||
String artifactId = tokens[0];
|
||||
String version = tokens[1];
|
||||
File dependencyJar=resolveDependencyJar(embedder,artifactId,version);
|
||||
if (dependencyJar == null) {
|
||||
if (optional) {
|
||||
System.err.println("cannot resolve optional dependency " + dep + " of " + shortName + "; skipping");
|
||||
continue;
|
||||
}
|
||||
throw new IOException("Could not resolve " + dep);
|
||||
}
|
||||
|
||||
File dst = new File(home, "plugins/" + artifactId + ".jpi");
|
||||
if(!dst.exists() || dst.lastModified()!=dependencyJar.lastModified()) {
|
||||
@@ -1600,9 +1611,6 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
|
||||
throws MavenEmbedderException, ComponentLookupException, AbstractArtifactResolutionException {
|
||||
final Artifact jpi = embedder.createArtifact(groupId, artifactId, version, "compile"/*doesn't matter*/, type);
|
||||
embedder.resolve(jpi, Arrays.asList(embedder.createRepository("http://maven.glassfish.org/content/groups/public/","repo")),embedder.getLocalRepository());
|
||||
if (jpi.getFile() == null) {
|
||||
throw new ArtifactNotFoundException("cannot find plugin dependency", jpi);
|
||||
}
|
||||
return jpi.getFile();
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import hudson.model.AbstractBuild;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.tasks.Builder;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -40,6 +41,7 @@ import java.io.IOException;
|
||||
public class SleepBuilder extends Builder {
|
||||
public final long time;
|
||||
|
||||
@DataBoundConstructor
|
||||
public SleepBuilder(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ final class WarExploder {
|
||||
if(!timestamp.exists() || (timestamp.lastModified()!=war.lastModified())) {
|
||||
System.out.println("Exploding jenkins.war at "+war);
|
||||
new FilePath(explodeDir).deleteRecursive();
|
||||
// TODO this can fail (race condition?) when running tests in parallel; need a three-state flag, and switch to a different explodeDir as needed
|
||||
new FilePath(war).unzip(new FilePath(explodeDir));
|
||||
if(!explodeDir.exists()) // this is supposed to be impossible, but I'm investigating HUDSON-2605
|
||||
throw new IOException("Failed to explode "+war);
|
||||
|
||||
Reference in new issue
Block a user