[Fixed Issue 465][issue-465]
- Remove asciidoctor site parts
- AS preparation for user guide.
- Remove asciidoctor site parts
- Replaced xml-apis with xerces-xmlParserAPI.
Added possibility to get mode detailed data from Maven Modules from Jobs/Builds
Thanks for that to Jakub Zacek.
- Remove google guava lib
- Removed also the creation of the shaded artifact
stashcause we do not rely on Guava anymore. So you can use the original artifact directly. - This results in a bumping of the version number cause it is a change which is breaking with previous version 0.3.8.
- CVE-2018-14718
- CVE-2018-14719
- CVE-2018-14720
- CVE-2018-14721
- CVE-2018-19360
- CVE-2018-19361
- CVE-2018-19362
Upgrade httpclient/httpmine/httpcore.
Upgrade JUnit
Upgrade assertj-core.
Upgrade Maven Plugins
Refactored Code Replaced UrlEscapers calls with EncodingUtils.
Add Unit Test for EncodingUtils.
Replace
Strings.isNullOrEmpty()with self implemented code.Add the crumbFlag as the 2nd parameter of getConsoleOutputText method
Added labels to computers
ComputerWithDetailscomputer = ... for (ComputerLabelassignedLabel : computer.getAssignedLabels()) { assignedLabel.getName() }
Change request method of
QuietDown()to POST
Added a build.stop() method which takes in a crumbFlag
Decoupled JenkinsServer and JenkinsHttpClient by extracting JenkinsHttpClient methods into public interface so that different implementations can be plugged into JenkinsServer if required
Added Closeable support to JenkinsServer and JenkinsHttpClient so that underlying resources can be cleaned up when instances no longer required
Added ability to modify offline cause for offline computers.
ComputerWithDetailscomputer = ... if (!computer.getOffline()){ computer.toggleOffline(); computer.changeOfflineCause("Scheduled for termination"); }
Add support for both client TLS and basic authentication.
HttpClientBuilderbuilder = HttpClientBuilder.create(); builder.setSslcontext(sslContext); JenkinsHttpClientclient = newJenkinsHttpClient(uri, builder, username, password); JenkinsServerjenkins = newJenkinsServer(client);
Useful utility methods refactored into utility classes.
NullPointerExceptionmay be thrown ifupstreamUrlisnullwhen converting cause toBuildCauseobject.NullPointerException is thrown unless isRunning() is called first.
Splitting fix made for jacoco reports from Jenkins #98. Thanks to Shah, Prince.
Added new api for streaming build logs
BuildWithDetailsbuild = ... // Get log with initial offsetintoffset = 40; Stringoutput = build.getConsoleOutputText(offset); // Stream logs (when build is in progress)BuildConsoleStreamListenerbuildListener = ... build.streamConsoleOutput(listener, 3, 420);
Thanks to Wojciech Trocki.
Fixed WARNING during build.
getViews()Do not useapi/json?depth=1cause of timeout.README.md Code grammar typos; Thanks to dwlee@woowahan.com.
Pull Request #229 Fix race condition in JenkinsTriggerHelper
Thanks for that to Veske.
Pull Request #239 Fixed Bug in build method to prevent building twice.
Thanks for the pull request #239 from ladventure/master
Pull Request #240 Fixed code duplication.
Thanks for the pull request #240 from Jonathan Bremer.
Pull Request #247 Add JavaDoc.
Thanks to aisuke-yoshimoto
Pull Request #262 Fix typo.
Thanks for Alberto Scotto.
Added new methods to JenkinsServer for stopping and restarting Jenkins. The methods are restart(Boolean crumbFlag), safeRestart(Boolean crumbFlag), exit(Boolean crumbFlag) and safeExit(Boolean crumbFlag)
Thanks for that to Chids.
- Changed Eclipse Formatting configuration.
- Correctly escaping
{and}for range syntax.
- Added a supplemental package with classifier
apachehttpwhich includes the packagesorg.apache.httpcomponents:httpclientandorg.apache.httpcomponents:httpcore.
The JenkinsServer class will return
JenkinsVersioninstead of String if you callgetJenkinsVersion().
publicclassJenkinsVersion ... {
publicbooleanisGreaterThan(Stringversion);
publicbooleanisGreaterOrEqual(Stringversion);
publicbooleanisLessThan(Stringversion);
publicbooleanisLessOrEqual(Stringversion);
publicbooleanisEqualTo(Stringversion);
}The JenkinsVersion class can be used to compare different versions with
each other.
JenkinsVersionjv = newJenkinsVersion("1.651.1");
assertThat(jv.isGreaterThan("1.651.1")).isFalse();Based on the differences between getting a TestReport for a MavenJob type and a freestyle job etc. you would have hit by getting 0 from
getTotalCount()like in the following code snippet:
JobWithDetailsjob = js.getJob("non-maven-test");
BuildlastCompletedBuild = job.getLastCompletedBuild();
TestReporttestReport = lastCompletedBuild.getTestReport();This is caused by the difference in the API of Jenkins which results in the following for a MavenJob type:
{
"_class" : "hudson.maven.reporters.SurefireAggregatedReport",
"failCount" : 0,
"skipCount" : 0,
"totalCount" : 489,
"urlName" : "testReport",
"childReports" : [
{
"child" : {
"_class" : "hudson.maven.MavenBuild",
"number" : 2,
"url" : "http://localhost:27100/buildserver/job/maven-test/com.soebes.subversion.sapm$sapm/2/"
},
"result" : {
"_class" : "hudson.tasks.junit.TestResult",
"testActions" : [
],
"duration" : 0.009,
"empty" : false,
"failCount" : 0,
"passCount" : 489,
"skipCount" : 0,
"suites" : [
{
"cases" : [
But for a non Maven job like freestyle job you will get the following:
{
"_class" : "hudson.tasks.junit.TestResult",
"testActions" : [
],
"duration" : 0.01,
"empty" : false,
"failCount" : 0,
"passCount" : 489,
"skipCount" : 0,
"suites" : [
{
"cases" : [
{
"testActions" : [
],
"age" : 0,
"className" : "com.soebes.subversion.sapm.AccessRuleGroupTest",
"duration" : 0.003,
This is exactly the cause for this result.
The API has been enhanced to get the correct result. This can be achieved by calling the following in cases where you have a non Maven job type.
TestResulttestResult = lastCompletedBuild.getTestResult();This means you need to take care yourself if you are getting the test results from Maven job type or non Maven job. (Future releases of the lib hopefully handle that in a more convenient way).
Consider Returning null from the "getTestReport()" of Build.java class for builds that Never run.
The type
BUILD_HAS_NEVER_RUNhas been enhanced to returnTestReport.NO_TEST_REPORTif you callgetTestReport()and returnBuildWithDetails.BUILD_HAS_NEVER_RUNif you calldetails()on the type.Furthermore
JobWithDetailsclass has been enhanced with the following methods:
publicclassJobWithDetails ... {
publicbooleanhasFirstBuildRun();
publicbooleanhasLastBuildRun();
publicbooleanhasLastCompletedBuildRun();
publicbooleanhasLastFailedBuildRun();
publicbooleanhasLastStableBuildRun();
publicbooleanhasLastSuccessfulBuildRun();
publicbooleanhasLastUnstableBuildRun();
publicbooleanhasLastUnsuccessfulBuildRun();
}to make checking more convenient. The following code snippet shows how you need to go before this change:
JobWithDetailsjob = server.getJob(jobName);
if (Build.BUILD_HAS_NEVER_RUN.equals(job.getLastBuild()) {
...
} else {
// Now we can get the TestReportjob.getLastBuild().getTestReport();
}This can now be simplified to the following:
JobWithDetailsjob = server.getJob(jobName);
if (job.hasLastBuildRun()) {
// Now we can get the TestReportjob.getLastBuild().getTestReport();
} else {
}Added methods to update/clear the description of a job.
publicclassJobWithDetails .. {
publicvoidupdateDescription(Stringdescription);
publicvoidupdateDescription(Stringdescription, booleancrumbFlag);
publicvoidclearDescription();
publicvoidclearDescription(booleancrumbFlag);Added methods to update the description and the display name of a build.
publicclassBuildWithDetails .. {
publicvoidupdateDisplayNameAndDescription(StringdisplayName, Stringdescription, booleancrumbFlag);
publicvoidupdateDisplayNameAndDescription(StringdisplayName, Stringdescription);
publicvoidupdateDisplayName(StringdisplayName, booleancrumbFlag);
publicvoidupdateDisplayName(StringdisplayName);
publicvoidupdateDescription(Stringdescription, booleancrumbFlag);
publicvoidupdateDescription(Stringdescription);
}Pull Request #206 added runScript with
crumbFlag.Thanks Rainer W.
publicclassJenkinsServer {
publicStringrunScript(Stringscript,booleancrumb);
}Fixed issue 197 Provide method for waiting until job has finished.
Added a helper class to support this.
publicclassJenkinsTriggerHelper {
publicBuildWithDetailstriggerJobAndWaitUntilFinished(StringjobName);
publicBuildWithDetailstriggerJobAndWaitUntilFinished(StringjobName, booleancrumbFlag);
publicBuildWithDetailstriggerJobAndWaitUntilFinished(StringjobName, Map<String, String> params);
publicBuildWithDetailstriggerJobAndWaitUntilFinished(StringjobName, Map<String, String> params,booleancrumbFlag);
}- Fixed Issue 104 all build* methods now return consistently
QueueReferenceto make it possible to query for a queued build and if a build from the queue has been cancelled or to see if a build is running.
publicclassJobextendsBaseModel {
publicQueueReferencebuild();
publicQueueReferencebuild(booleancrumbFlag);
publicQueueReferencebuild(Map<String, String> params);
publicQueueReferencebuild(Map<String, String> params, booleancrumbFlag);
}Fixed Issue 203 with pull request #204 of RainerW github@inforw.de
Added methods getJobXml and updateJob with folder parameter.
publicclassJenkinsServer {
StringgetJobXml(FolderJobfolder, StringjobName);
voidupdateJob(FolderJobfolder, StringjobName, StringjobXml, booleancrumbFlag);
}Added
publicclassQueueItemextendsBaseModel {
List<QueueItemActions> getActions();
}and the new QueueItemActions will offer access to the
actions.
Added an deleteJob method with a crumbFlag.
publicclassJenkinsServer {
deleteJob(FolderJobfolder, StringjobName, booleancrumbFlag);
}Added several methods for creating/updating views.
publicclassJenkinsServer {
voidcreateView(StringviewName, StringviewXml);
voidcreateView(StringviewName, StringviewXml, BooleancrumbFlag);
voidcreateView(FolderJobfolder, StringviewName, StringviewXml);
voidcreateView(FolderJobfolder, StringviewName, StringviewXml, BooleancrumbFlag);
voidupdateView(StringviewName, StringviewXml);
voidupdateView(StringviewName, StringviewXml, booleancrumbFlag);
}Returning null instead of IOException if view is not found in JenkinsServer.getView
MavenJobsWithDetails is now in line with JobWithDetails and returns
MavenBuild.BUILD_HAS_NEVER_RUN in cases where the run has not taken
place yet.
publicclassMavenJobWithDetails { publicMavenBuildgetLastBuild();
publicMavenBuildgetLastCompletedBuild();
publicMavenBuildgetLastFailedBuild();
publicMavenBuildgetLastStableBuild();
publicMavenBuildgetLastSuccessfulBuild();
publicMavenBuildgetLastUnstableBuild();
publicMavenBuildgetLastUnsuccessfulBuild();
}The getBuilds() method will return an empty list instead of NULL in cases no
builds exists.
Fixed grammar and changed Build.BUILD_HAS_NEVER_RAN into Build.BUILD_HAS_NEVER_RUN
publicclassMavenJobWithDetails { publicMavenBuildgetFirstBuild();
}Enhanced the QueueItem to add information about the task (QueueTask).
publicclassQueueItem {
publicQueueTaskgetTask();
}Added two methods to get all builds and a range of builds so we are more in line wiht JobWithDetails.
publicclassMavenJobWithDetails { publicList<MavenBuild> getAllBuilds();
publicList<MavenBuild> getAllBuilds(Rangerange);
}Fixed #182 remove duplicated code
- maven-release-plugin to 2.5.3
- maven-site-plugin to 3.5.1
- maven-shade-plugin to 2.4.3
- maven-jar-plugin to 3.0.2
- maven-source-plugin 3.0.1
- maven-surefire/failsafe-plugin to 2.19.1
- maven-resources-plugin to 3.0.1
- Add missing maven-javadoc-plugin 2.10.4
Upgraded Maven Plugins JENKINS-35108
- maven-clean-plugin to 3.0.0
- maven-resources-plugin to 3.0.0
- maven-jar-plugin to 3.0.0
Fixed issue 176 HttpResponseException: Not Found (createJob) Based on the wrong usage of the sub methods using crumbFlag=true instead of crumbFlag=false.
JenkinsJob.details() produced NPE which has been got via view.getJob().
The implementation BuildWithDetails.getCauses() could cause an
NPE which now has been imroved to prevent it. Thanks for hint
which brought me to reconsider the implementation.
Serveral issues fixed related to using logging framework issue-161, issue-113 and JENKINS-35002
Added slf4j-api as foundation for logging. Using log4j2-slf4j-impl in jenkins-client-it-docker for logging. As a user you can now decide which logging framework you would like to use.
Changed the structure and integrated Docker IT
The attributes of the following classes have been made private. They are only accessible via getters/setters.
MavenArtifact, ComputerWithDetails, Executable, FolderJob,
JobWithDetails, MavenJobWithDetails, MavenModule, MavenModuleRecord,
PluginManager
The getTestReport has been moved up from MavenBuild into
Build class. This makes the TestReport accessible
from any kind of build and not only from a Maven build.
jenkins.getComputerSet().getComputer() produced an error.
Changed getComputer() into getComputers() cause it returns
a list an not only a single computer.
Based on the above problem the Executor needed to be changed to
represent the correct data which is being returned.
publicclassComputerSet {
publicList<ComputerWithDetails> getComputers();
}publicclassExecutor {
publicJobgetCurrentExecutable();
publicJobgetCurrentWorkUnit();
}Fixed issue 169 Add crumbFlag to renameJob
Added supplemental renameJob method which supports crumbFlag. Furthermore
added renameJob which supports folder with and without crumbFlag.
So we now have the following methods to rename jobs:
publicclassJenkinsServer {
publicvoidrenameJob(StringoldJobName, StringnewJobName) throwsIOException;
publicvoidrenameJob(StringoldJobName, StringnewJobName, BooleancrumbFlag) throwsIOException;
publicvoidrenameJob(FolderJobfolder, StringoldJobName, StringnewJobName) throwsIOException;
publicvoidrenameJob(FolderJobfolder, StringoldJobName, StringnewJobName, BooleancrumbFlag) throwsIOException;
}Fixed issue 168 deletejobs in folder
Added new method to delete a job within a folder.
publicclassJenkinsServer {
publicvoiddeleteJob(FolderJobfolder, StringjobName) throwsIOException;
}Changing getLocalContext(), setLocalContext()
The protected method getLocalContext() now returns
HttpContext instead of BasicHttpContext.
So the API has changed from the following:
publicclassJenkinsServer {
protectedBasicHttpContextgetLocalContext();
protectedvoidsetLocalContext(BasicHttpContextlocalContext); .
}into this:
publicclassJenkinsServer {
protectedHttpContextgetLocalContext();
protectedvoidsetLocalContext(HttpContextlocalContext); .
}Apart from that the visibility of the class PreemptiveAuth has been changed
from package private to public.
Get Jenkins Version from http header
publicclassJenkinsServer {
publicStringgetVersion();
.
}publicclassJobWithDetails {
publicStringgetDescription();
.
}The following methods have been changed to return Collections.emtpyList() if
no builds exists or have ran before.
getAllBuilds(Rangerange);
getAllBuilds(), getBuilds()The JobWithDetails class contains several methods which could
have returned null. This has been changed to return non null values.
publicList<Job> getDownstreamProjects();
publicList<Job> getUpstreamProjects();They will return Collections.emptyList().
The following methods will return Build.BUILD_HAS_NEVER_RAN in
cases where no build has executed for the appropriate methods instead
of the previous null value.
publicBuildgetFirstBuild();
publicBuildgetLastBuild();
publicBuildgetLastCompletedBuild();
publicBuildgetLastFailedBuild();
publicBuildgetLastStableBuild();
publicBuildgetLastSuccessfulBuild();
publicBuildgetLastUnstableBuild();
publicBuildgetLastUnsuccessfulBuild();Added getAllBuilds(), getAllBuilds(Range range)
The JobWithDetails has been enhanced with two methods
to get all builds which exists or a range can be used
to select.
Note: There seemed to be no option to extract simply the number of existing builds of a particular job via the REST API.
publicclassJobWithDetails {
publicList<Build> getAllBuilds() throwsIOException;
publicList<Build> getAllBuilds(Rangerange) throwsIOException;
}publicclassJenkinsServer {
renameJob(StringjobName, StringnewJobName) throwsIOException;
.
}Added toggleOffline Node
Added toggleOffline to ComputerWithDetails class.
publicclassComputerWithDetails {
publicvoidtoggleOffline(booleancrumbFlag) throwsIOException;
publicvoidtoggleOffline() throwsIOException;
}Some HTTP calls to jenkins result in a 302, which currently throws an HttpResponseException
Fixed. by changing call to client.post(, crumbFlag = true) into client.post(, crumbFlag = false).
Added getPluginManager() to JenkinsServer
PluginManagergetPluginManager() throwsIOException;Added method to get Plugin.
publicclassPluginManagerextendsBaseModel {
publicList<Plugin> getPlugins()
}Plugin class contains methods to get informations about
the plugins plus a PluginDependency class.
Added getFileFromWorkspace() to Job
Added method getFileFromWorkspace() to Job class to get a file
from workspace in Jenkins.
StringgetFileFromWorkspace(StringfileName)TestCase class enhanced
Now the TestCase contains the information
about the errorDetails and the errorStackTrace of
a failed test case.
StringgetErrorDetails();
StringgetErrorStackTrace()Added disableJob, enabledJob The following methods have been added to support enabling and disabling jobs.
voiddisableJob(StringjobName);
voiddisableJob(StringjobName, booleancrumbFlag);
voidenableJob(StringjobName);
voidenableJob(StringjobName, booleancrumbFlag);Fixed #128 Added OfflineCause as a real object in ComputerWithDetails
Added OfflineCause class which can now being used
as a return type for the attribute offlineCause instead
of Object in ComputerWithDetails.
publicclassComputerWithDetails {
ObjectofflineCause;
..
}into the following which also influenced the appropriate return types of the getters:
into
publicclassComputerWithDetails {
OfflineCauseofflineCause;
publicOfflineCausegetOfflineCause() throwsIOException;
}Fixed #135 Created documentation area Started a documentation area under src/site/ for either Markdown or asciidoctor.
Fixed #130 org.jvnet.hudson:xstream I needed to remove the toString method from View class which uses the XStream classes which does not make sense from my point of view.
Fixed #144 Problems with spaces in paths and job names
Fixed #133 How do we find out which system the built was build on?
Now BuildWithDetails API has been enhanced with the following method get
the information on which node this build has ran.
StringgetBuiltOn();Fixed #146 duration / estimatedDuration are long
The API in BuildWithDetailshas been changed to represent the change
in datatype.
intgetDuration();
intgetEstimatedDuration();into:
longgetDuration();
longgetEstimatedDuration();Fixed #111 A missing dependency to jaxen caused problems The problem was that the dependency has missed from the compile scope which caused problems for users to use. The dependency was there via transitive dependency of a test scoped artifact.
Do not propagate IOException when GET for /CrumbIssuer fails
Added Cloudbees Folder support
The following methods have been added to support FolderJob type.
voidcreateFolder(StringjobName, BooleancrumbFlag);
Optional<FolderJob> getFolderJob(Jobjob);
Map<String, Job> getJobs(FolderJobfolder);
Map<String, Job> getJobs(FolderJobfolder, Stringview);
Map<String, View> getViews(FolderJobfolder);
ViewgetView(FolderJobfolder, Stringname);
JobWithDetailsgetJob(FolderJobfolder, StringjobName);
MavenJobWithDetailsgetMavenJob(FolderJobfolder, StringjobName);
voidcreateJob(FolderJobfolder, StringjobName, StringjobXml);
voidcreateJob(FolderJobfolder, StringjobName, StringjobXml, BooleancrumbFlag);JobWithDetails has been enhanced with information about the first build.
BuildgetFirstBuild()The JenkinsServer API has been enhanced to get information about the Queue
QueueItemgetQueueItem(QueueReferenceref) throwsIOExceptionBuildgetBuild(QueueItemq) throwsIOExceptionThe JenkinsHttpClient API has been changed from the following:
JenkinsHttpClient(URIuri, DefaultHttpClientdefaultHttpClient);into
JenkinsHttpClient(URIuri, CloseableHttpClientclient);Furthermore the JenkinsHttpClient API has been enhanced with the following
method which allows to create an unauthenticated Jenkins HTTP client.
JenkinsHttpClient(URIuri, HttpClientBuilderbuilder);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.
QueueReferencebuild(Map<String, String> params, booleancrumbFlag) throwsIOException;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:
MapgetLoadStatistics();The new one looks like this:
LoadStatisticsgetLoadStatistics() throwsIOExceptionYou 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.
JenkinsServerjenkins = newJenkinsServer(newURI("http://localhost:8080/jenkins"), "admin", "password");
MavenJobWithDetailsmavenJob = js.getMavenJob("javaee");
BuildWithDetailsdetails = 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:
BuildChangeSetchangeSet = 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
JenkinsServerjs = newJenkinsServer(URI.create("http://jenkins-server/"));
MavenJobWithDetailsmavenJob = js.getMavenJob("MavenJob");
BuildWithDetailsdetails = mavenJob.getLastSuccessfulBuild().details();
TestReporttestReport = 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.