The Jenkins API Client For Java has now moved under the umbrella of the Jenkins GitHub Organization.
To get started add the following dependency to your project
<dependency>
<groupId>com.offbytwo.jenkins</groupId>
<artifactId>jenkins-client</artifactId>
<version>0.3.5</version>
</dependency>
Starting with Release 0.4.0 the groupId/artifactId will change (NOT YET DONE!)
<dependency>
NOT YET FINALIZED
<groupId>org.jenkins-ci.lib</groupId>
<artifactId>java-client-api</artifactId>
<version>0.4.0</version>
</dependency>
The com.offbytwo.jenkins.JenkinsServer
class provides the main entry
point into the API. You can create a reference to the Jenkins server
given its location and (optionally) a username and password/token.
JenkinsServer jenkins = new JenkinsServer(new URI("http://localhost:8080/jenkins"), "admin", "password")
At the top level you can access all of the currently defined jobs. This returns a map of job names (in lower case) to jobs.
Map<String, Job> jobs = jenkins.getJobs()
The Job class provides only summary information (name and url). You can retrieve details as follows
JobWithDetails job = jobs.get("My Job").details()
The JobWithDetails
class provides you with access to the list of
builds (and related information such as the first, last, successful,
etc) and upstream and downstream projects.
To run only unit tests without invoking the integration tests use the following command:
mvn clean install -DskipITs
To run integration tests simply start
mvn -Prun-its clean verify
There is also a separate project which contains [integration tests][integration-tests] which are running with a special version of Jenkins within a Docker container to check several aspects of the API which can't be covered by the usual integration tests.
You can find details about the different releases in the Release Notes.
- Release 0.4.0.
- Release 0.3.6.
- Release 0.3.5.
- Release 0.3.4.
- Release 0.3.3.
- Release 0.3.2.
- Release 0.3.1.
If you find a problem please create an
issue in the ticket system with the component java-client-api
and describe what is going wrong or what you expect to happen.
If you have a full working example or a log file this is also helpful.
You should of course describe only a single issue in a single ticket and not
mixing up several different things into a single issue.
Before you create a pull request it is necessary to create an issue in
the ticket system before with the component java-client-api
and describe what the problem is or what kind of feature you would like
to add. Afterwards you can create an appropriate pull request.
It is required if you want to get a Pull request to be integrated into please squash your commits into a single commit which references the issue in the commit message.
A pull request has to fulfill only a single ticket and should never create/add/fix several issues in one, cause otherwise the history is hard to read and to understand and makes the maintenance of the issues and pull request hard or to be honest impossible.
Furthermore it is neccesary to create appropriate entries into the ReleaseNotes.md
file as well.
You can ask questions in the mailing list which is also intended as discussion forum for development.
http://jenkinsci.github.io/java-client-api/
Copyright (C) 2013, Cosmin Stejerean, Karl Heinz Marbaise, and contributors.
Distributed under the MIT license: http://opensource.org/licenses/MIT