JobWithDetails has been enhanced with information about the first build.
Build getFirstBuild()
The JenkinsServer
API has been enhanced to get information about the Queue
QueueItem getQueueItem(QueueReference ref) throws IOException
Build getBuild(QueueItem q) throws IOException
The JenkinsHttpClient
API has been changed from the following:
JenkinsHttpClient(URI uri, DefaultHttpClient defaultHttpClient);
into
JenkinsHttpClient(URI uri, CloseableHttpClient client);
Furthermore the JenkinsHttpClient
API has been enhanced with the following
method which allows to create an unauthenticated Jenkins HTTP client.
JenkinsHttpClient(URI uri, HttpClientBuilder builder);
The Build
class Stop
method needed to be changed internally based on an
inconsistencies in Jenkins versions. (This might be change in future). There
are versions 1.565 which supports the stop method as a post call, version
1.609.1 support it as a get call and 1.609.2 as a post call.
The Job
class has been enhanced to trigger parameterized builds.
QueueReference build(Map<String, String> params, boolean crumbFlag) throws IOException;
Until to Release 0.3.0 the getLoadStatistics()
method returned a simple Map
which
needed to be changed to represent the information which is returned.
So the old one looked like this:
Map getLoadStatistics();
The new one looks like this:
LoadStatistics getLoadStatistics() throws IOException
You can see how it works by using the JenkinsLoadStatisticsExample.java.
The API for getExecutors()
has been changed from a simple Map
into something
more meaningful.
The old one looked like this:
List<Map> getExecutors();
where as the new API looks like this:
List<Executor> getExecutors();
This will result in a list of Executor which contain supplemental informations about the appropriate executor.
This release contains new functionality like support to get the list of existing views. This can be accomplished by using the following:
Map<String, View> views = jenkins.getViews();
The change for getExecutors()
which is documented in API changes.
The information about the ChangeSet
and the culprit
has been improved.
JenkinsServer jenkins = new JenkinsServer(new URI("http://localhost:8080/jenkins"), "admin", "password");
MavenJobWithDetails mavenJob = js.getMavenJob("javaee");
BuildWithDetails details = mavenJob.getLastSuccessfulBuild().details();
So now you can extract the causes which is related to the trigger which triggered the build.
List<BuildCause> causes = details.getCauses();
With the help of getChangeSet()
you can extract the changeset information of your build:
BuildChangeSet changeSet = details.getChangeSet();
By using the changeSet.getKind()
you would expect to get the kind of version control
which has been used. If you use Git or Subversion this is true but unfortunately it
is not true for all version control systems (for example TFS).
The information about files which have been changed an other information can be extracted by using the following:
List<BuildChangeSetItem> items = changeSet.getItems();
If you like to get a better overview check the example file in the project.
Extract TestReport from Jenkins
JenkinsServer js = new JenkinsServer(URI.create("http://jenkins-server/"));
MavenJobWithDetails mavenJob = js.getMavenJob("MavenJob");
BuildWithDetails details = mavenJob.getLastSuccessfulBuild().details();
TestReport testReport = mavenJob.getLastSuccessfulBuild().getTestReport();
You can extract the information about the tests which have run which contains information about the number of tests, failed tests and skipped tests etc. For a more detailed example take a look into the project.