Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.

Commit 0f704da

Browse files
committed
1 parent df3cee2 commit 0f704da

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
###Bug fixes:
33
- fixing [JENKINS-22325](https://issues.jenkins-ci.org/browse/JENKINS-22325) - local job fails when not sending any parameters to remote job
44
- 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
5-
- 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.
5+
- 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
6+
- fixing [JENKINS-22427](https://issues.jenkins-ci.org/browse/JENKINS-22427) - fails when remote job waits for available executor
7+
68

79
#2.1 (Feb 17th, 2014)
810
###New Feature/Enhancement:

src/main/java/org/jenkinsci/plugins/ParameterizedRemoteTrigger/RemoteBuildConfiguration.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ private String buildGetUrl(String job, String securityToken) {
440440
* @throws IOException
441441
*/
442442
private void failBuild(Exception e, BuildListener listener) throws IOException {
443-
e.getStackTrace();
443+
System.out.print(e.getStackTrace());
444444
if (this.getShouldNotFailBuild()) {
445445
listener.error("Remote build failed for the following reason, but the build will continue:");
446446
listener.error(e.getMessage());
@@ -667,7 +667,6 @@ public JSONObject sendHTTPCall(String urlString, String requestType, AbstractBui
667667

668668
JSONObject responseObject = null;
669669

670-
try {
671670
URL buildUrl = new URL(urlString);
672671
connection = (HttpURLConnection) buildUrl.openConnection();
673672

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

684683
if (!usernameTokenConcat.equals(":")) {
685684
// token-macro replacment
686-
usernameTokenConcat = TokenMacro.expandAll(build, listener, usernameTokenConcat);
685+
try {
686+
usernameTokenConcat = TokenMacro.expandAll(build, listener, usernameTokenConcat);
687+
} catch (MacroEvaluationException e) {
688+
this.failBuild(e, listener);
689+
} catch (InterruptedException e) {
690+
this.failBuild(e, listener);
691+
}
687692

688693
byte[] encodedAuthKey = Base64.encodeBase64(usernameTokenConcat.getBytes());
689694
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthKey));
690695
}
691-
696+
try {
692697
connection.setDoInput(true);
693698
connection.setRequestProperty("Accept", "application/json");
694699
connection.setRequestMethod(requestType);
695700
// wait up to 5 seconds for the connection to be open
696701
connection.setConnectTimeout(5000);
697702
connection.connect();
698-
703+
699704
InputStream is = connection.getInputStream();
700-
705+
701706
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
702707
String line;
703708
// String response = "";
704709
StringBuilder response = new StringBuilder();
705-
710+
706711
while ((line = rd.readLine()) != null) {
707712
response.append(line);
708713
}
709714
rd.close();
710-
715+
711716
// JSONSerializer serializer = new JSONSerializer();
712717
// need to parse the data we get back into struct
713718
//listener.getLogger().println("Called URL: '" + urlString + "', got response: '" + response.toString() + "'");
@@ -724,12 +729,16 @@ public JSONObject sendHTTPCall(String urlString, String requestType, AbstractBui
724729
}
725730

726731
} catch (IOException e) {
727-
// something failed with the connection, so throw an exception to mark the build as failed.
728-
this.failBuild(e, listener);
729-
} catch (MacroEvaluationException e) {
730-
this.failBuild(e, listener);
731-
} catch (InterruptedException e) {
732-
this.failBuild(e, listener);
732+
//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.
733+
//So we basically pretend like the error didn't happen.
734+
String callingMethod = Thread.currentThread().getStackTrace()[2].getMethodName();
735+
if(connection.getResponseCode() == 404 && callingMethod == "getBuildStatus"){
736+
return null;
737+
}else{
738+
//something failed with the connection, so throw an exception to mark the build as failed.
739+
this.failBuild(e, listener);
740+
}
741+
733742
} finally {
734743
// always make sure we close the connection
735744
if (connection != null) {

0 commit comments

Comments
 (0)