retrofit-jenkins-api

retrofit wrapper for jenkins api calls

License

License

Categories

Categories

Jenkins Build Tools Continuous Integration and Continuous Delivery
GroupId

GroupId

com.teotas
ArtifactId

ArtifactId

jenkins-api
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

retrofit-jenkins-api
retrofit wrapper for jenkins api calls
Project URL

Project URL

https://github.com/Garce78/retrofit-jenkins-api
Source Code Management

Source Code Management

https://github.com/Garce78/retrofit-jenkins-api

Download jenkins-api

How to add to project

<!-- https://jarcasting.com/artifacts/com.teotas/jenkins-api/ -->
<dependency>
    <groupId>com.teotas</groupId>
    <artifactId>jenkins-api</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.teotas/jenkins-api/
implementation 'com.teotas:jenkins-api:1.0'
// https://jarcasting.com/artifacts/com.teotas/jenkins-api/
implementation ("com.teotas:jenkins-api:1.0")
'com.teotas:jenkins-api:jar:1.0'
<dependency org="com.teotas" name="jenkins-api" rev="1.0">
  <artifact name="jenkins-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.teotas', module='jenkins-api', version='1.0')
)
libraryDependencies += "com.teotas" % "jenkins-api" % "1.0"
[com.teotas/jenkins-api "1.0"]

Dependencies

compile (12)

Group / Artifact Type Version
com.squareup.retrofit2 : retrofit jar 2.0.1
com.squareup.retrofit2 : converter-gson jar 2.0.1
com.squareup.retrofit2 : converter-scalars jar 2.0.1
com.squareup.retrofit2 : converter-simplexml jar 2.0.1
com.squareup.retrofit2 : converter-jackson jar 2.0.1
org.apache.httpcomponents : httpcore jar 4.4.4
org.projectlombok : lombok jar RELEASE
org.slf4j : slf4j-api jar RELEASE
com.google.guava : guava jar RELEASE
org.apache.httpcomponents : httpclient jar RELEASE
org.json : json jar RELEASE
org.assertj : assertj-core jar RELEASE

test (1)

Group / Artifact Type Version
junit : junit jar RELEASE

Project Modules

There are no modules declared in this project.

Retrofit Jenkins API Library

Summary

This is a light-weight Java wrapper for Jenkins api calls. Using a combination of Retrofit 2.0, Lombok, and the not-so-secret api call paths of Jenkins to retrieve View, Job, and Build information (among other things) for use in whatever way you see fit.

Setup

To get started with this library, simply download the repository (or pull in from the public maven repo //linkgoeshere ) and declare/instantiate your JenkinsAPI object like so:

JenkinsAPIConnection connection = JenkinsAPIConnection.builder().jenkinsBaseURL("http://myjenkinsurl.com")
                                                                .userName("Add.Me")
                                                                .userAuthToken("addme")
                                                                .build();
JenkinsAPI jenkins = new JenkinsAPI(connection);

and you're good to go!

JenkinsAPI.java versus other API.java classes in this package

When you're sifting through the contents of this project, or referencing any of its classes via dot syntax in a smart IDE (like IntelliJ), you might notice that there are several *API.java classes you can instantiate, such as JobAPI.

YOU DO NOT NEED TO DIRECTLY INSTANTIATE EACH OF THESE CLASSES WITH A CONNECTION TO USE THEM

The JenkinsAPI class will lazy-load these other APIs as needed. All you have to do is call the right one when you want it. Here's an example of what you might want to do and how you might accomplish it with JenkinsAPI:

JenkinsAPI jenkins = new JenkinsAPI(connection);
JenkinsJobResponse job = jenkins.jobAPI().getJob("my-job");
ArrayList<JenkinsView> views = jenkins.viewAPI().getViews(); 

This implementation pattern will yield less code clutter, while maintaining some of the efficiency of using individual api classes via the lazy-load. It certainly beats having to do this:

JobAPI jobAPI = new JobAPI(connection);
jobAPI.getJob("my-job");
ViewAPI viewAPI = new ViewAPI(connection);
viewAPI.getViews();

But if you want/need to use the individual API classes there's nothing stopping you, just make sure you keep track of what the connection creds are (if you need to change them up here or there) and which url you're using (if you have multiple Jenkins instances for some reason).

Versions

Version
1.0