diff --git a/ReleaseNotes.md b/ReleaseNotes.md index d9bd5705..4873a003 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -2,7 +2,10 @@ ## Release 0.3.8 (NOT RELEASED YET) - * ? + * [Fixed Issue 220][issue-220] + + `getViews()` Do not use `api/json?depth=1` cause timeout. + ### API Changes @@ -949,6 +952,7 @@ TestReport testReport = mavenJob.getLastSuccessfulBuild().getTestReport(); [issue-209]: https://github.com/jenkinsci/java-client-api/issues/209 [issue-211]: https://github.com/jenkinsci/java-client-api/issues/211 [issue-215]: https://github.com/jenkinsci/java-client-api/issues/215 +[issue-220]: https://github.com/jenkinsci/java-client-api/issues/220 [pull-123]: https://github.com/jenkinsci/java-client-api/pull/123 [pull-149]: https://github.com/jenkinsci/java-client-api/pull/149 [pull-158]: https://github.com/jenkinsci/java-client-api/pull/158 diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java index c3d1c5e5..0ae72b67 100644 --- a/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java +++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java @@ -188,7 +188,7 @@ public Map getViews() throws IOException { * @throws IOException in case of an error. */ public Map getViews(FolderJob folder) throws IOException { - List views = client.get(toBaseUrl(folder) + "?depth=1", MainView.class).getViews(); + List views = client.get(toBaseUrl(folder), MainView.class).getViews(); return Maps.uniqueIndex(views, new Function() { @Override public String apply(View view) { @@ -203,7 +203,6 @@ public String apply(View view) { item.setClient(client); } - // return view.getName().toLowerCase(); return view.getName(); } }); diff --git a/jenkins-client/src/test/java/com/offbytwo/jenkins/JenkinsTestManualTestReport.java b/jenkins-client/src/test/java/com/offbytwo/jenkins/JenkinsTestManualTestReport.java index 09b24d96..03db37db 100644 --- a/jenkins-client/src/test/java/com/offbytwo/jenkins/JenkinsTestManualTestReport.java +++ b/jenkins-client/src/test/java/com/offbytwo/jenkins/JenkinsTestManualTestReport.java @@ -1,8 +1,12 @@ package com.offbytwo.jenkins; +import java.io.IOException; import java.net.URI; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import org.junit.Ignore; import org.junit.Test; import com.offbytwo.jenkins.model.Build; @@ -10,10 +14,11 @@ import com.offbytwo.jenkins.model.TestReport; import com.offbytwo.jenkins.model.TestResult; import com.offbytwo.jenkins.model.TestSuites; +import com.offbytwo.jenkins.model.View; public class JenkinsTestManualTestReport { - @Test + @Ignore public void firstTest() throws Exception { JenkinsServer js = new JenkinsServer(URI.create("http://localhost:10090/buildserver/"), "admin", "admin"); @@ -37,4 +42,15 @@ public void firstTest() throws Exception { List suites = testResult.getSuites(); } + + @Test + public void anotherTest() throws IOException { + JenkinsServer js = new JenkinsServer(URI.create("http://localhost:10090/buildserver/"), "admin", "admin"); + Map views = js.getViews(); + for (Entry item : views.entrySet()) { + View value = item.getValue(); + System.out.println("URL: " + value.getUrl()); + } + + } }