提交 70706d9d 编写于 作者: J Jesse Glick

Merge branch 'master' of github.com:jenkinsci/jenkins

......@@ -42,7 +42,7 @@ THE SOFTWARE.
<properties>
<staplerFork>true</staplerFork>
<stapler.version>1.197</stapler.version>
<stapler.version>1.198</stapler.version>
</properties>
<dependencies>
......
......@@ -37,7 +37,9 @@ import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.bind.JavaScriptMethod;
import org.kohsuke.stapler.framework.adjunct.AdjunctsInPage;
import org.kohsuke.stapler.jelly.DefaultScriptInvoker;
import org.xml.sax.SAXException;
import javax.servlet.ServletException;
import java.io.IOException;
......@@ -45,6 +47,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -61,6 +64,8 @@ public class RenderOnDemandClosure {
private final Map<String,Object> variables;
private final String currentDescriptorByNameUrl;
private final Set<String> adjuncts;
public RenderOnDemandClosure(JellyContext context, String attributesToCapture) {
List<Script> bodyStack = new ArrayList<Script>();
for (JellyContext c = context; c!=null; c=c.getParent()) {
......@@ -78,6 +83,8 @@ public class RenderOnDemandClosure {
currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl();
this.variables = PackedMap.of(variables);
this.adjuncts = AdjunctsInPage.get().getIncluded();
}
/**
......@@ -96,6 +103,13 @@ public class RenderOnDemandClosure {
context = new JellyContext(context);
context.setVariable("org.apache.commons.jelly.body",bodyStack[i]);
}
try {
AdjunctsInPage.get().assumeIncluded(adjuncts);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to resurrect adjunct context",e);
} catch (SAXException e) {
LOGGER.log(Level.WARNING, "Failed to resurrect adjunct context",e);
}
return context;
}
......
......@@ -221,7 +221,7 @@ public final class MavenArtifact implements Serializable {
*/
public void archive(MavenBuildProxy build, File file, BuildListener listener) throws IOException, InterruptedException {
if (build.isArchivingDisabled()) {
listener.getLogger().println("[JENKINS] Archiving disabled - not archiving " + file);
LOGGER.fine("Archiving disabled - not archiving " + file);
}
else {
FilePath target = getArtifactArchivePath(build,groupId,artifactId,version);
......
......@@ -153,19 +153,16 @@ public class MavenArtifactArchiver extends MavenReporter {
// do we have any assembly artifacts?
// System.out.println("Considering "+assemblies+" at "+MavenArtifactArchiver.this);
// new Exception().fillInStackTrace().printStackTrace();
if (assemblies!=null) {
if (build.isArchivingDisabled()) {
listener.getLogger().println("[JENKINS] Archiving disabled");
} else if (assemblies!=null) {
for (File assembly : assemblies) {
if(mavenArtifacts.contains(assembly))
continue; // looks like this is already archived
if (build.isArchivingDisabled()) {
listener.getLogger().println("[JENKINS] Archiving disabled - not archiving " + assembly);
}
else {
FilePath target = build.getArtifactsDir().child(assembly.getName());
listener.getLogger().println("[JENKINS] Archiving "+ assembly+" to "+target);
new FilePath(assembly).copyTo(target);
// TODO: fingerprint
}
FilePath target = build.getArtifactsDir().child(assembly.getName());
listener.getLogger().println("[JENKINS] Archiving "+ assembly+" to "+target);
new FilePath(assembly).copyTo(target);
// TODO: fingerprint
}
}
......
......@@ -52,15 +52,20 @@ public class RenderOnDemandTest extends HudsonTestCase {
*/
public void testScript() throws Exception {
HtmlPage p = createWebClient().goTo("self/testScript");
assertNull(p.getElementById("loaded"));
p.getElementById("button").click();
// all AJAX calls complete before the above method returns
assertNotNull(p.getElementById("loaded"));
ScriptResult r = p.executeJavaScript("x");
assertEquals("foo",r.getJavaScriptResult().toString());
assertEquals("xxx",r.getJavaScriptResult().toString());
r = p.executeJavaScript("y");
assertEquals("yyy",r.getJavaScriptResult().toString());
// if you want to test this in the browser
System.out.println("Try http://localhost:"+localPort+"\"self/testScript");
System.out.println("Try http://localhost:"+localPort+"/self/testScript");
interactiveBreak();
}
}
<j:jelly xmlns:j="jelly:core">
y = "yyy";
</j:jelly>
\ No newline at end of file
......@@ -32,6 +32,7 @@ THE SOFTWARE.
<input type="button" value="Test" id="button"/>
<script>
var x = null;
var y = null;
$("button").onclick = function() {
renderOnDemand(document.getElementsBySelector('.lazy')[0]);
}
......@@ -39,10 +40,11 @@ THE SOFTWARE.
<l:renderOnDemand clazz="lazy">
<div id="eye">hello</div>
<div id="loaded">loaded</div>
<script>
x = "foo";
x = "xxx";
</script>
<script src="externalScript"></script>
</l:renderOnDemand>
</l:main-panel>
</l:layout>
......
......@@ -364,6 +364,14 @@ function parseHtml(html) {
return c.firstChild;
}
/**
* Evaluates the script in global context.
*/
function geval(script) {
// see http://perfectionkills.com/global-eval-what-are-the-options/
return (this.execScript || eval)(script);
}
/**
* Emulate the firing of an event.
*
......@@ -396,7 +404,7 @@ var tooltip;
function registerValidator(e) {
e.targetElement = findFollowingTR(e, "validation-error-area").firstChild.nextSibling;
e.targetUrl = function() {
return eval(this.getAttribute("checkUrl"));
return eval(this.getAttribute("checkUrl")); // need access to 'this'
};
var method = e.getAttribute("checkMethod");
if (!method) method = "get";
......@@ -492,7 +500,7 @@ function isInsideRemovable(e) {
*/
function renderOnDemand(e,callback,noBehaviour) {
if (!e || !Element.hasClassName(e,"render-on-demand")) return;
var proxy = eval(e.getAttribute("proxy"));
var proxy = geval(e.getAttribute("proxy"));
proxy.render(function (t) {
var contextTagName = e.parentNode.tagName;
var c;
......@@ -537,7 +545,7 @@ function evalInnerHtmlScripts(text,callback) {
});
} else {
q.push(function(cont) {
eval(s.match(matchOne)[2]);
geval(s.match(matchOne)[2]);
cont();
});
}
......@@ -708,7 +716,7 @@ var jenkinsRules = {
(function() {
var cmdKeyDown = false;
var mode = e.getAttribute("script-mode") || "text/x-groovy";
var readOnly = eval(e.getAttribute("script-readOnly")) || false;
var readOnly = geval(e.getAttribute("script-readOnly")) || false;
var w = CodeMirror.fromTextArea(e,{
mode: mode,
......@@ -2134,7 +2142,7 @@ function validateButton(checkUrl,paramList,button) {
var s = rsp.getResponseHeader("script");
if(s!=null)
try {
eval(s);
geval(s);
} catch(e) {
window.alert("failed to evaluate "+s+"\n"+e.message);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册