Skip to content
Permalink
Browse files
[FIXED JENKINS-21525] Make command to run an external job work with f…
…olders.
  • Loading branch information
jglick committed Jan 27, 2014
1 parent 18646cb commit c9d69d36bdaaa149bb64887218b35e2ca260da07
Showing with 9 additions and 8 deletions.
  1. +3 −1 changelog.html
  2. +6 −7 core/src/main/java/hudson/Main.java
@@ -55,7 +55,9 @@
<!-- 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.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 static int remotePost(String[] args) throws Exception {
}
}

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 static int remotePost(String[] args) throws Exception {
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 static int remotePost(String[] args) throws Exception {
} 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.

0 comments on commit c9d69d3

Please sign in to comment.