If you are getting errors like HttpRequestBase not present or unable to resolve class groovyx.net.http.HTTPBuilder on your Jenkins jobs then you will need to manually download and install some missing libraries.
You could do it the 'insecure' way (I do not recommend) and use the "Grab" feature:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.2')
However, this is the modern enlightened era, and we don't want to create a dependencies on third party services. Instead you should download pre-compiled JARs (or compile them yourself from source if that's your thing) and place them in the Jenkin's 'war/WEB-INF/lib' directory.
JAR Download Locations
Always download pre-compiled binaries from a trusted source. Or check the SHA256 sum. The following links should remain evergreen forever, but that's never guaranteed.
Note: HTTPBuilder (0.7.2) requires Apache HTTPClient Library version 4.5.x.
- HTTPBuilder 0.7.2: https://mvnrepository.com/artifact/org.codehaus.groovy.modules.http-builder/http-builder/0.7.2
- Apache HTTPClient Library 4.5.x: https://hc.apache.org/downloads.cgi
From the Apache HTTPClient, you will need at minimum the following JAR's:
commons-codec-1.11.jar commons-logging-1.2.jar httpclient-4.5.14.jar httpcore-4.4.16.jar
HTTPBuilder is only a single JAR:
http-builder-0.7.2.jar
Installing into Jenkins
If you are using the Jenkins port on FreeBSD you can download the required JARs and place them into the following location:
/usr/local/jenkins/war/WEB-INF/lib/commons-codec-1.11.jar
/usr/local/jenkins/war/WEB-INF/lib/commons-logging-1.2.jar
/usr/local/jenkins/war/WEB-INF/lib/http-builder-0.7.2.jar
/usr/local/jenkins/war/WEB-INF/lib/httpclient-4.5.14.jar
/usr/local/jenkins/war/WEB-INF/lib/httpcore-4.4.16.jar
Restart Jenkins and your job should execute successfully.
Closing Thoughts
This is no doubt a very inelegant solution to the problem. Identifying the root cause is a little tricky. Sure, it's true that the HTTPBuilder developer should have adhered to the golden rule and included those requisite libraries as part of his code base or pre-compiled JAR. However that wouldn't have solved the problem. Jenkins has no reason to include HTTPBuilder with it's code base.
Maybe the proper solution is to not use HTTPBuilder? Or perhaps there is something about the Global Libraries feature in Jenkin's that's lacking (or not well documented) around the ability to load external JAR's?
Whatever the root cause is, the following remains true (the golden rule):
"if it does not work with out it, then it should be part of it."
- Log in to post comments