提交 c9d69d36 编写于 作者: J Jesse Glick

[FIXED JENKINS-21525] Make command to run an external job work with folders.

上级 18646cb9
......@@ -55,7 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Using <code>java -jar jenkins-core.jar folder/external-monitor-job cmd …</code> did not work.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21525">issue 21525</a>)
</ul>
</div><!--=TRUNK-END=-->
......
......@@ -37,7 +37,6 @@ import java.io.Writer;
import java.net.HttpRetryException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.nio.charset.Charset;
......@@ -104,14 +103,14 @@ public class Main {
}
}
String projectNameEnc = URLEncoder.encode(projectName,"UTF-8").replaceAll("\\+","%20");
URL jobURL = new URL(home + "job/" + Util.encode(projectName).replace("/", "/job/") + "/");
{// check if the job name is correct
HttpURLConnection con = open(new URL(home+"job/"+projectNameEnc+"/acceptBuildResult"));
HttpURLConnection con = open(new URL(jobURL, "acceptBuildResult"));
if (auth != null) con.setRequestProperty("Authorization", auth);
con.connect();
if(con.getResponseCode()!=200) {
System.err.println(projectName+" is not a valid job name on "+home+" ("+con.getResponseMessage()+")");
System.err.println(jobURL + " is not a valid external job (" + con.getResponseCode() + " " + con.getResponseMessage() + ")");
return -1;
}
}
......@@ -156,11 +155,11 @@ public class Main {
w.write("</log><result>"+ret+"</result><duration>"+(System.currentTimeMillis()-start)+"</duration></run>");
w.close();
String location = home+"job/"+projectNameEnc+"/postBuildResult";
URL location = new URL(jobURL, "postBuildResult");
while(true) {
try {
// start a remote connection
HttpURLConnection con = open(new URL(location));
HttpURLConnection con = open(location);
if (auth != null) con.setRequestProperty("Authorization", auth);
if (crumbField != null && crumbValue != null) {
con.setRequestProperty(crumbField, crumbValue);
......@@ -182,7 +181,7 @@ public class Main {
} catch (HttpRetryException e) {
if(e.getLocation()!=null) {
// retry with the new location
location = e.getLocation();
location = new URL(e.getLocation());
continue;
}
// otherwise failed for reasons beyond us.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册