|
6 | 6 | [](https://javadoc.io/doc/com.offbytwo.jenkins/jenkins-client) |
7 | 7 |
|
8 | 8 | ## something fix and new feature at extension branch |
9 | | -## Important Note |
10 | 9 |
|
11 | | -The Jenkins API Client For Java has now moved under the umbrella of the Jenkins GitHub Organization. |
12 | | - |
13 | | -## What is the "Jenkins API Client for Java"? |
14 | | - |
15 | | -This library is just a piece of java code which uses the REST API of jenkins. |
16 | | -This means you can trigger builds, extract informations about jobs or builds |
17 | | -etc. The information you can extract will be represented in java objects which |
18 | | -you can reuse for other purposes or integrate this library into other parts for |
19 | | -a higher level of integration. |
20 | | - |
21 | | -## Getting Started |
22 | | - |
23 | | -If you like to use this library you need to add the library as a dependency |
24 | | -to your project. This can be done by using a Maven dependency like the following: |
25 | | - |
26 | | -```xml |
27 | | -<dependency> |
28 | | - <groupId>com.offbytwo.jenkins</groupId> |
29 | | - <artifactId>jenkins-client</artifactId> |
30 | | - <version>0.3.8</version> |
31 | | -</dependency> |
32 | | -``` |
33 | | - |
34 | | -This can also being done by defining a Gradle dependency like this: |
35 | | - |
36 | | -``` |
37 | | -compile 'com.offbytwo.jenkins:jenkins-client:0.3.8' |
38 | | -``` |
39 | | - |
40 | | -Starting with a future release 0.4.0 the groupId/artifactId will change (NOT YET DONE!) |
41 | | - |
42 | | -```xml |
43 | | -<dependency> |
44 | | - NOT YET FINALIZED NOR RELEASED !!! |
45 | | - <groupId>org.jenkins-ci.lib</groupId> |
46 | | - <artifactId>java-client-api</artifactId> |
47 | | - <version>0.4.0</version> |
48 | | -</dependency> |
49 | | -``` |
50 | | - |
51 | | -## Usage |
52 | | - |
53 | | -The `com.offbytwo.jenkins.JenkinsServer` class provides the main entry |
54 | | -point into the API. You can create a reference to the Jenkins server |
55 | | -given its location and (optionally) a username and password/token. |
56 | | - |
57 | | -```java |
58 | | -JenkinsServer jenkins = new JenkinsServer(new URI("http://localhost:8080/jenkins"), "admin", "password") |
59 | | -``` |
60 | | - |
61 | | -At the top level you can access all of the currently defined |
62 | | -jobs. This returns a map of job names (in lower case) to jobs. |
63 | | - |
64 | | -```java |
65 | | -Map<String, Job> jobs = jenkins.getJobs() |
66 | | -``` |
67 | | - |
68 | | -The Job class provides only summary information (name and url). You can retrieve details as follows |
69 | | - |
70 | | -```java |
71 | | -JobWithDetails job = jobs.get("My Job").details() |
72 | | -``` |
73 | | - |
74 | | -The `JobWithDetails` class provides you with access to the list of |
75 | | -builds (and related information such as the first, last, successful, |
76 | | -etc) and upstream and downstream projects. |
77 | | - |
78 | | -## Running Tests |
79 | | -To run only unit tests without invoking the integration tests use the following command: |
80 | | - |
81 | | -``` |
82 | | -mvn clean install -DskipITs |
83 | | -``` |
84 | | - |
85 | | -## Running Integration Tests |
86 | | -To run integration tests simply start |
87 | | - |
88 | | -``` |
89 | | -mvn -Prun-its clean verify |
90 | | -``` |
91 | | - |
92 | | -There is also a module which contains [integration tests][integration-tests] |
93 | | -which are running with a special version of Jenkins |
94 | | -within a Docker container to check several aspects of the API which can't be |
95 | | -covered by the usual integration tests. |
96 | | - |
97 | | -## Release Notes |
98 | | - |
99 | | -You can find details about the different releases in the [Release Notes](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md). |
100 | | - |
101 | | - * [Release 0.3.9 NOT RELEASED YET](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-039). |
102 | | - * [Release 0.3.8](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-038). |
103 | | - * [Release 0.3.7](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-037). |
104 | | - * [Release 0.3.6](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-036). |
105 | | - * [Release 0.3.5](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-035). |
106 | | - * [Release 0.3.4](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-034). |
107 | | - * [Release 0.3.3](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-033). |
108 | | - * [Release 0.3.2](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-032). |
109 | | - * [Release 0.3.1](https://github.com/jenkinsci/java-client-api/blob/master/ReleaseNotes.md#release-031). |
110 | | - |
111 | | -## Contribution |
112 | | - |
113 | | -### Creating Issues |
114 | | - |
115 | | -If you find a problem please create an |
116 | | -[issue in the ticket system with the component `java-client-api`](https://issues.jenkins-ci.org/projects/JENKINS/) |
117 | | -and describe what is going wrong or what you expect to happen. |
118 | | -If you have a full working example or a log file this is also helpful. |
119 | | -You should of course describe only a single issue in a single ticket and not |
120 | | -mixing up several different things into a single issue. |
121 | | - |
122 | | -### Creating a Pull Request |
123 | | - |
124 | | -Before you create a pull request it is necessary to create an issue in |
125 | | -the [ticket system before with the component `java-client-api`](https://issues.jenkins-ci.org/browse/JENKINS) |
126 | | -and describe what the problem is or what kind of feature you would like |
127 | | -to add. Afterwards you can create an appropriate pull request. |
128 | | - |
129 | | -It is required if you want to get a Pull request to be integrated into please |
130 | | -squash your commits into a single commit which references the issue in the |
131 | | -commit message which looks like this: |
132 | | - |
133 | | -``` |
134 | | -Fixed #Issue |
135 | | - o Description. |
136 | | -``` |
137 | | - |
138 | | -This makes it simpler to merge it and this will also close the |
139 | | -appropriate issue automatically in one go. This make the life as |
140 | | -maintainer a little bit easier. |
141 | | - |
142 | | -A pull request has to fulfill only a single ticket and should never |
143 | | -create/add/fix several issues in one, cause otherwise the history is hard to |
144 | | -read and to understand and makes the maintenance of the issues and pull request |
145 | | -hard or to be honest impossible. |
146 | | - |
147 | | -Furthermore it is necessary to create appropriate entries into the `ReleaseNotes.md` |
148 | | -file as well. |
149 | | - |
150 | | - |
151 | | -## Help & Questions |
152 | | - |
153 | | -You can ask questions in the [mailing list](https://groups.google.com/d/forum/java-client-api) |
154 | | - which is also intended as discussion forum for development. |
155 | | - |
156 | | -## Generated Site |
157 | | - |
158 | | -http://jenkinsci.github.io/java-client-api/ |
159 | | - |
160 | | -## License |
161 | | - |
162 | | -Copyright (C) 2013, Cosmin Stejerean, Karl Heinz Marbaise, and contributors. |
163 | | - |
164 | | -Distributed under the MIT license: http://opensource.org/licenses/MIT |
165 | | - |
166 | | -[integration-tests]: https://github.com/jenkinsci/java-client-api/tree/master/jenkins-client-it-docker |
0 commit comments