jenkins-pipeline-shared-libraries-gradle-plugin
jenkins-pipeline-shared-libraries-gradle-plugin copied to clipboard
Using http-request plugin in integration tests fails due to wrong Guava version
Jenkins core still uses Guava 11: https://github.com/jenkinsci/jenkins/blob/d4690b20f9dc170f7657c6b36df2c0d48a217ebe/bom/pom.xml#L42
My integration test uses http-request-plugin 1.8.26. Looking at the dependencies of the Gradle plugin, Guava 18 is used:
$ gradle dependencies | grep guava
| | | | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:11.0.1 -> 18.0
+--- com.google.guava:guava:18.0
| | | | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:11.0.1 -> 18.0
+--- com.google.guava:guava:18.0
| | | | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:11.0.1 -> 18.0
+--- com.google.guava:guava:18.0
| | | | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:11.0.1 -> 18.0
+--- com.google.guava:guava:18.0
| | | +--- com.google.guava:guava:11.0.1
+--- com.google.guava:guava:11.0.1 (*)
+--- com.google.guava:guava:18.0 (n)
| | | | +--- com.google.guava:guava:13.0.1 -> 18.0
| | | +--- com.google.guava:guava:11.0.1 -> 18.0
| | | | | +--- com.google.guava:guava:14.0 -> 18.0
| | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:18.0
| | | | +--- com.google.guava:guava:11.0.1
| +--- com.google.guava:guava:11.0.1
| | | | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:11.0.1 -> 18.0
+--- com.google.guava:guava:18.0
| | | | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:11.0.1 -> 18.0
| | \--- com.google.guava:guava:11.0.1 -> 18.0
+--- com.google.guava:guava:18.0
| | | | +--- com.google.guava:guava:11.0.1 -> 18.0
| +--- com.google.guava:guava:11.0.1 -> 18.0
| | \--- com.google.guava:guava:11.0.1 -> 18.0
+--- com.google.guava:guava:18.0
Guava 18 does not contain com.google.common.collect.Ranges
any more and my integration test using http-request-plugin fails to import that class. See https://github.com/jenkinsci/http-request-plugin/blob/eb45bd7e963903f355c22377266fe907c9ea45f7/src/main/java/jenkins/plugins/http_request/HttpRequest.java#L27
Found the cause of my problem
pluginDependencies {
dependency("org.jenkins-ci.plugins", "jira", "3.1.1") // has dependency to guava 18.0
}
downgrading that plugin to 3.0.9 solves my dependency problem.
https://github.com/jenkinsci/jira-plugin/blob/master/pom.xml#L142
I was able to work around this issue without downgrading any plugins by adding the following to build.gradle
:
dependencies {
integrationTestImplementation enforcedPlatform("org.jenkins-ci.main:jenkins-bom:${jenkinsVersion}")
}
(Here, jenkinsVersion
is the version of Jenkins core I am using.)
The Jenkins core BOM defines the old versions of Groovy and Guice used by Jenkins core. By importing this BOM using enforcedPlatform
, the versions defined in the BOM override the newer versions found in the dependency graph. Note that you must be using Gradle 5.0 or later to be able to import Maven BOMs.
https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin/issues/65#issuecomment-730512926 solved my issues with latest plugins and Jenkins pipeline tests.
I'll look to make use of enforcedPlatform
for the Jenkins BOM or some other dependency maneuvering to ensure runtime compatibility in the next release.