Skip to content

Commit

Permalink
Merge pull request #8 from wgreven/dont-fail-on-404
Browse files Browse the repository at this point in the history
Don't fail on a 404 status
  • Loading branch information
morficus committed Feb 8, 2015
2 parents 5988ef1 + 5894fe8 commit 5e7cba3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
Expand Up @@ -28,6 +28,7 @@
import org.kohsuke.stapler.StaplerRequest;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -803,7 +804,13 @@ public JSONObject sendHTTPCall(String urlString, String requestType, AbstractBui
connection.setConnectTimeout(5000);
connection.connect();

InputStream is = connection.getInputStream();
InputStream is;
try {
is = connection.getInputStream();
} catch (FileNotFoundException e) {
// In case of a e.g. 404 status
is = connection.getErrorStream();
}

BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
Expand Down Expand Up @@ -1048,7 +1055,7 @@ public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
*
* <p>
* If you don't want fields to be persisted, use <tt>transient</tt>.
*/
v */
private CopyOnWriteList<RemoteJenkinsServer> remoteSites = new CopyOnWriteList<RemoteJenkinsServer>();

/**
Expand Down Expand Up @@ -1107,5 +1114,9 @@ public RemoteJenkinsServer[] getRemoteSites() {

return remoteSites.toArray(new RemoteJenkinsServer[this.remoteSites.size()]);
}

public void setRemoteSites(RemoteJenkinsServer... remoteSites) {
this.remoteSites.replaceBy(remoteSites);
}
}
}
@@ -0,0 +1,39 @@
package org.jenkinsci.plugins.ParameterizedRemoteTrigger;

import hudson.model.FreeStyleProject;
import net.sf.json.JSONObject;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class RemoteBuildConfigurationTest {
@Rule
public JenkinsRule jenkinsRule = new JenkinsRule();

@Test
public void testRemoteBuild() throws Exception {
jenkinsRule.jenkins.setCrumbIssuer(null);

JSONObject authenticationMode = new JSONObject();
authenticationMode.put("value", "none");
JSONObject auth = new JSONObject();
auth.put("authenticationMode", authenticationMode);

String remoteUrl = jenkinsRule.getURL().toString();
RemoteJenkinsServer remoteJenkinsServer =
new RemoteJenkinsServer(remoteUrl, "JENKINS", false, auth);
RemoteBuildConfiguration.DescriptorImpl descriptor =
jenkinsRule.jenkins.getDescriptorByType(RemoteBuildConfiguration.DescriptorImpl.class);
descriptor.setRemoteSites(remoteJenkinsServer);

FreeStyleProject remoteProject = jenkinsRule.createFreeStyleProject();

FreeStyleProject project = jenkinsRule.createFreeStyleProject();
RemoteBuildConfiguration remoteBuildConfiguration = new RemoteBuildConfiguration(
remoteJenkinsServer.getDisplayName(), false, remoteProject.getFullName(), "",
"", null, null, false, true, 1);
project.getBuildersList().add(remoteBuildConfiguration);

jenkinsRule.buildAndAssertSuccess(project);
}
}

0 comments on commit 5e7cba3

Please sign in to comment.