Skip to content

jenkinsci/okhttp-api-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OkHttp API Plugin for Jenkins

This plugin manages okhttp library version for Jenkins plugins.

This plugin includes the following packages:

  • com.squareup.okio:okio - required by okhttp

  • com.squareup.okhttp3:okhttp

  • com.squareup.okhttp3:logging-interceptor - commonly used by a number of plugins

Other com.squareup.okhttp3.* packages may be added upon request.

This plugin does not include the following packages:

  • com.squareup.okhttp:* (all v2.x okhttp packages) - The last release in this line was v2.7.5 (2016-02-25). It is not longer supported in any way. Including them would only increase the risk of this plugin introducing security vulnerabilities and bugs. Plugins that want to use this plugin should update to use okhttp3.

  • com.squareup.okhttp3:okhttp-urlconnection - This package contained the OkHttpUrlFactory class which provides a facade implementing HttpURLConnection for okhttp. OkHttpUrlFactory was deprecated in v3.0.0-RC1 (2016-01-02) and was removed as of v3.14.x (2019-03-14) so there is no reason to include this package. Plugins that use OkHttpUrlFactory and want to use this plugin are strongly advised to upgrade to OkHttp’s request/response API directly. If that is not feasible, they can copy and paste ObsoleteUrlFactory.java into their project.

Migration from async-http-client tips

Use the okhttp-api utility classes

JenkinsOKHttpClient

Use this class to instantiate an OkHttpClient.Builder that already has the Jenkins proxy configuration pre-set. It does not update the configuration, so if you want to get any change on Jenkins proxy (if there was some since the client was firstly instantiated) reflected in your client then you need to call newClientBuilder again passing the existing client.

As noted in the documentation, new clients coming from the builder share most of the resources, so there is no need to keep the same client as a singleton (normally).

Replace RequestBuilder with OkHttpClient.Builder. Replace Realm with Authenticator:

public RequestBuilder authenticate(RequestBuilder builder) {
    return builder.setRealm(realm);
}

Becomes:

public OkHttpClient.Builder authenticate(OkHttpClient.Builder builder) {
    return builder.authenticator(authScheme);
}

Adapter to Java Future API

Most of the usages of the AHC library are tied to the Java Future API, so it’s very convenient to keep the interfaces untouched while changing the implementation. To do this the okhttp-api plugin provides the OkHttpFuture class, which is an adapter from the native okhttp async API to the Java Future API. So you can do something like this:

return new OkHttpFuture<T>(call, new ResponseConverter<T>() {
    @Override
    public T onResponse(Call call, Response response) throws IOException {
        // handle the response
    }

    @Override
    public void onFailure(Call call, IOException e) {
        // handle the failure
    }
);

Plugins using this plugin

  • github-api

Updating to a newer version of okhttp

The current plan is to release a series of progressive updates along the okhttp 4.x release line until the plugin is up-to-date with current releases.

This is project includes a few tests (using the github-api library) that sanity check that the okhttp version being included doesn’t completely break existing behavior.

The okhttp library in general is large enough that tests beyond sanity checks would have limited usefulness. With a few small exceptions, OkHttp 4.x is both binary- and Java source-compatible with OkHttp 3.x. The okhttp team has worked very hard to not introduce breaking changes. Still, be sure to carefully review the okhttp release notes before updating to a newer version okhttp.

Plugins bundling okhttp

Below are the list of other plugins that bundle on okhttp in various ways rather than using okhttp-api-plugin. The plugins are grouped based which version and packages they bundle.

okhttp 4.x

low risk

The okhttp-api-plugin has updated to the 4.x release line. This means updating these plugins to use okhttp-api-plugin has very low risk.

defensics: okhttp-4.6.0.jar
octoperf: okhttp-4.3.0.jar
teamscale-upload: okhttp-4.2.1.jar
tuleap-api: okhttp-4.4.1.jar
tuleap-git-branch-source: okhttp-4.5.0.jar
worktile: okhttp-4.5.0.jar

okhttp 3.x

Low risk

okhttp 3.x (aka okhttp3 v3.x) has strong api stability across its lifetime. Most 3.x APIs remain unchanged in 4.x.

BlazeMeterJenkinsPlugin: okhttp-3.6.0.jar
adobe-cloud-manager: okhttp-3.14.7.jar
alauda-devops-pipeline: okhttp-3.12.0.jar
alauda-devops-sync: okhttp-3.12.0.jar
alauda-kubernetes-support: okhttp-3.12.0.jar
alauda-pipeline: okhttp-3.9.0.jar
appcenter: okhttp-3.14.3.jar
atlassian-bitbucket-server-integration: okhttp-3.14.1.jar
atlassian-jira-software-cloud: okhttp-3.14.1.jar
azure-artifact-manager: okhttp-3.14.1.jar
azure-credentials-ext: okhttp-3.12.6.jar
ca-apm: okhttp-3.1.1.jar
cloudshell-sandbox: okhttp-3.12.0.jar
conjur-credentials: okhttp-3.11.0.jar
conjur-simple-integration: okhttp-3.11.0.jar
docker-swarm: okhttp-3.10.0.jar
easyqa: okhttp-3.3.1.jar
elastest: okhttp-3.12.0.jar
fabric-beta-publisher: okhttp-3.12.0.jar
fedora-module-build-system: okhttp-3.8.1.jar
fortify-on-demand-uploader: okhttp-3.9.0.jar
git-changelog: okhttp-3.2.0.jar
github-api: okhttp-3.12.12.jar
graphql-server: okhttp-3.2.0.jar
hubot-steps: okhttp-3.12.0.jar
ibm-continuous-release: okhttp-3.5.0.jar
influxdb-query: okhttp-3.5.0.jar
influxdb: okhttp-3.14.4.jar
jira-steps: okhttp-3.14.7.jar
jx-pipelines: okhttp-3.8.1.jar
jx-resources: okhttp-3.12.0.jar
kubernetes-cd: okhttp-3.14.3.jar
kubernetes-ci: okhttp-3.2.0.jar
kubernetes-client-api: okhttp-3.12.6.jar
kubernetes-pipeline-devops-steps: okhttp-3.9.0.jar
macstadium-orka: okhttp-3.14.2.jar
minio-storage: okhttp-3.7.0.jar
nomad: okhttp-3.10.0.jar
notify-events: okhttp-3.8.1.jar
onesky: okhttp-3.4.2.jar
openshift-pipeline: okhttp-ws-3.3.1.jar
openshift-pipeline: okhttp-3.3.1.jar
openshift-sync: okhttp-3.12.0.jar
openstack-cloud: okhttp-3.9.1.jar
openstack-cloud: openstack4j-okhttp-3.6.jar
outbound-webhook: okhttp-3.8.1.jar
pangolin-testrail-connector: okhttp-3.8.1.jar
performance-signature-dynatrace: okhttp-3.14.4.jar
performance-signature-dynatracesaas: okhttp-3.14.4.jar
pipeline-huaweicloud-plugin: okhttp-3.10.0.jar
protecode-sc: okhttp-3.13.1.jar
qiniu: okhttp-3.14.4.jar
qualityclouds: okhttp-3.3.0.jar
rapid7-insightvm-container-assessment: okhttp-3.6.0.jar
remoting-kafka: okhttp-3.12.0.jar
sonar: okhttp-3.7.0.jar
sweagle: okhttp-3.4.2.jar
testquality-updater: okhttp-3.5.0.jar
urbancode-velocity: okhttp-3.5.0.jar
webhook-eventsource: okhttp-3.3.0.jar
xframium: okhttp-3.10.0.jar
yet-another-docker-plugin: okhttp-3.14.4.jar
yet-another-docker-plugin: docker-java-transport-okhttp-3.2.0.jar

okhttp-urlconnection 3.x

Code changes required

Support for okhttp-urlconnection was dropped in 3.14.x and later. It only valid in 3.12.x and earlier.

Plugins that use OkHttpUrlFactory are strongly advised to upgrade to OkHttp’s request/response API directly. If that is not feasible, they can copy and paste ObsoleteUrlFactory.java into their project.

azure-acs: okhttp-urlconnection-3.11.0.jar
azure-ad: okhttp-3.11.0.jar
azure-ad: okhttp-urlconnection-3.11.0.jar
azure-app-service: okhttp-3.11.0.jar
azure-app-service: okhttp-urlconnection-3.11.0.jar
azure-artifact-manager: okhttp-3.14.1.jar
azure-batch-parallel: okhttp-3.3.1.jar
azure-batch-parallel: okhttp-urlconnection-3.3.1.jar
azure-commons: okhttp-3.12.0.jar
azure-commons: okhttp-urlconnection-3.11.0.jar
azure-container-agents: okhttp-3.11.0.jar
azure-container-agents: okhttp-urlconnection-3.11.0.jar
azure-container-registry-tasks: okhttp-3.12.0.jar
azure-container-registry-tasks: okhttp-urlconnection-3.11.0.jar
azure-credentials-ext: okhttp-3.12.6.jar
azure-credentials: okhttp-3.12.6.jar
azure-credentials: okhttp-urlconnection-3.12.2.jar
azure-dev-spaces: okhttp-3.12.12.jar
azure-dev-spaces: okhttp-ws-2.7.5.jar
azure-function: okhttp-3.4.2.jar
azure-function: okhttp-urlconnection-3.4.2.jar
azure-iot-edge: okhttp-3.4.2.jar
azure-iot-edge: okhttp-urlconnection-3.4.2.jar
azure-vm-agents: okhttp-3.4.2.jar
azure-vm-agents: okhttp-urlconnection-3.4.2.jar
azure-vmss: okhttp-3.14.7.jar
azure-vmss: okhttp-urlconnection-3.4.2.jar
service-fabric: okhttp-3.4.2.jar
service-fabric: okhttp-urlconnection-3.4.2.jar
upload-pgyer: okhttp-3.10.0.jar
upload-pgyer: okhttp-urlconnection-3.10.0.jar

okhttp 2.x

Code changes required

This plugin does not include okhttp v2.x. This was done intentionally to avoid potential security issues related to bundling a version that is no longer maintained in any way.

The plugins below could be updated to use okhttp-api-plugin if they upgrade to using okhttp3.

There is some risk of this plugin affecting the plugins below - both okhttp and okhttp3 depend on okio. However, okio is also extremely stable and is unlikely to introduce breaking changes.

alauda-devops-pipeline: okhttp-2.7.5.jar
alauda-devops-sync: okhttp-2.7.5.jar
alauda-kubernetes-support: okhttp-ws-2.7.5.jar
alauda-kubernetes-support: okhttp-2.7.5.jar
bitbucket-approve: okhttp-2.1.0.jar
coding-webhook: okhttp-urlconnection-2.5.0.jar
coding-webhook: okhttp-2.5.0.jar
fortify: okhttp-2.7.5.jar
frugal-testing: okhttp-2.7.5.jar
git-changelog: okhttp-2.7.5.jar
http-post: okhttp-2.1.0.jar
incapptic-connect-uploader: okhttp-2.7.5.jar
jclouds-jenkins: jclouds-okhttp-2.2.0.jar
jclouds-jenkins: okhttp-2.2.0.jar
kiuwanJenkinsPlugin: okhttp-2.7.5.jar
kubernetes-ci: okhttp-2.7.2.jar
kubernetes-ci: okhttp-ws-2.7.2.jar
mdt-deployment: okhttp-2.3.0.jar
release-helper: okhttp-2.4.0.jar