public List<Build> getAllBuilds() throws IOException {
        String path = "/";

        try {
            List<Build> builds = client.get(path + "job/" + EncodingUtils.encode(this.getName())
                    + "?tree=allBuilds[number[*],url[*],queueId[*]]", AllBuilds.class).getAllBuilds();

            if (builds == null) {
                return Collections.emptyList();
            } else {
                return builds.stream()
                        .map(s -> buildWithClient(s))
                        .collect(toList());
            }
        } catch (HttpResponseException e) {
            // TODO: Thinks about a better handling if the job does not exist?
            if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
                // TODO: Check this if this is necessary or a good idea?

                return null;
            }
            throw e;
        }

    }
public List < Build > getAllBuilds ( ) throws IOException { String path = "/" ; try { List < Build > builds = client . get ( path + "job/" + EncodingUtils . encode ( this . getName ( ) ) + "?tree=allBuilds[number[*],url[*],queueId[*]]" , AllBuilds . class ) . getAllBuilds ( ) ; if ( builds == null ) { return Collections . emptyList ( ) ; } else { return builds . stream ( ) . map ( s -> buildWithClient ( s ) ) . collect ( toList ( ) ) ; } } catch ( HttpResponseException e ) { if ( e . getStatusCode ( ) == HttpStatus . SC_NOT_FOUND ) { return null ; } throw e ; } }
This method will give you back all builds which exists independent of the
number. You should be aware that this can be much in some cases if you
have more than 100 builds which is by default limited by Jenkins
{@link #getBuilds()}. This method limits it to particular information
which can be later used to get supplemental information about a
particular build {@link Build#details()} to reduce the amount of data
which needed to be transfered.

@return the list of {@link Build}. In case of no builds have been
executed yet return {@link Collections#emptyList()}.
@throws IOException In case of failure.
@see <a href="https://issues.jenkins-ci.org/browse/JENKINS-30238">Jenkins
Issue</a>