Skip to content
Permalink
Browse files

fixing JENKINS-22427 (https://issues.jenkins-ci.org/browse/JENKINS-22427

)
  • Loading branch information
morficus committed Apr 7, 2014
1 parent df3cee2 commit 0f704da096418c11c543c36382efc997b6125a2a
@@ -2,7 +2,9 @@
###Bug fixes:
- fixing [JENKINS-22325](https://issues.jenkins-ci.org/browse/JENKINS-22325) - local job fails when not sending any parameters to remote job
- fixing [JENKINS-21470](https://issues.jenkins-ci.org/browse/JENKINS-21470) - UI does not display that a build is using a file to get the parameter list
- fixing [JENKINS-22493](https://issues.jenkins-ci.org/browse/JENKINS-22493) - 400 when remote job has default parameters and parameters are not explicitly list them.
- fixing [JENKINS-22493](https://issues.jenkins-ci.org/browse/JENKINS-22493) - 400 when remote job has default parameters and parameters are not explicitly list them
- fixing [JENKINS-22427](https://issues.jenkins-ci.org/browse/JENKINS-22427) - fails when remote job waits for available executor


#2.1 (Feb 17th, 2014)
###New Feature/Enhancement:
@@ -440,7 +440,7 @@ private String buildGetUrl(String job, String securityToken) {
* @throws IOException
*/
private void failBuild(Exception e, BuildListener listener) throws IOException {
e.getStackTrace();
System.out.print(e.getStackTrace());
if (this.getShouldNotFailBuild()) {
listener.error("Remote build failed for the following reason, but the build will continue:");
listener.error(e.getMessage());
@@ -667,7 +667,6 @@ public JSONObject sendHTTPCall(String urlString, String requestType, AbstractBui

JSONObject responseObject = null;

try {
URL buildUrl = new URL(urlString);
connection = (HttpURLConnection) buildUrl.openConnection();

@@ -683,31 +682,37 @@ public JSONObject sendHTTPCall(String urlString, String requestType, AbstractBui

if (!usernameTokenConcat.equals(":")) {
// token-macro replacment
usernameTokenConcat = TokenMacro.expandAll(build, listener, usernameTokenConcat);
try {
usernameTokenConcat = TokenMacro.expandAll(build, listener, usernameTokenConcat);
} catch (MacroEvaluationException e) {
this.failBuild(e, listener);
} catch (InterruptedException e) {
this.failBuild(e, listener);
}

byte[] encodedAuthKey = Base64.encodeBase64(usernameTokenConcat.getBytes());
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthKey));
}

try {
connection.setDoInput(true);
connection.setRequestProperty("Accept", "application/json");
connection.setRequestMethod(requestType);
// wait up to 5 seconds for the connection to be open
connection.setConnectTimeout(5000);
connection.connect();

InputStream is = connection.getInputStream();

BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
// String response = "";
StringBuilder response = new StringBuilder();

while ((line = rd.readLine()) != null) {
response.append(line);
}
rd.close();

// JSONSerializer serializer = new JSONSerializer();
// need to parse the data we get back into struct
//listener.getLogger().println("Called URL: '" + urlString + "', got response: '" + response.toString() + "'");
@@ -724,12 +729,16 @@ public JSONObject sendHTTPCall(String urlString, String requestType, AbstractBui
}

} catch (IOException e) {
// something failed with the connection, so throw an exception to mark the build as failed.
this.failBuild(e, listener);
} catch (MacroEvaluationException e) {
this.failBuild(e, listener);
} catch (InterruptedException e) {
this.failBuild(e, listener);
//If we get a 404 when trying to check a builds status (aka: called from "getBuildStatus") it just means that the build hasn't been queued up because there aren't any more executors available to call the remote server.
//So we basically pretend like the error didn't happen.
String callingMethod = Thread.currentThread().getStackTrace()[2].getMethodName();
if(connection.getResponseCode() == 404 && callingMethod == "getBuildStatus"){
return null;
}else{
//something failed with the connection, so throw an exception to mark the build as failed.
this.failBuild(e, listener);
}

} finally {
// always make sure we close the connection
if (connection != null) {

0 comments on commit 0f704da

Please sign in to comment.
You can’t perform that action at this time.