Skip to content

Instantly share code, notes, and snippets.

@zdtsw
Created September 3, 2018 17:20
Show Gist options
  • Save zdtsw/d57c24f65250c82968e5131f98e72160 to your computer and use it in GitHub Desktop.
Save zdtsw/d57c24f65250c82968e5131f98e72160 to your computer and use it in GitHub Desktop.
How to add dependency for your jenkins shard lib
Background:
i need to use http-builder for my jenkins shardlib and by default the jar file is not available to use with a simple "import"
Solution:
from code:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
import groovyx.net.http.HTTPBuilder
//you can check maven center if there is a newer version (>0.7.1) released, so far this version has been parked there for a couple of years
loggin to jenkins master
//this only need to be done on master, sharelib does not require on jenkins slaves.
to $jenkins//.groovy/grapes/
there might be several resolved-caller-all-caller-workin* files. you can leave them as is or delete them.does not matter for real.
create folder : "org.codehaus.groovy.modules.http-builder/http-builder" , then
// this is name after your grab with group and module value
create a file : "ivy-0.7.1.xml", you can name it whatever you like as long as it is a xml file.
create a folder: "jars", manually download http builder jar from maven center and put into this "jars" folder
put such config into "ivy-0.7.1.xml"
?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="org.codehaus.groovy.modules.http-builder" module="http-builder" revision="0.7.1">
<license name="" />
<description homepage="">http builder 0.7.1</description>
</info>
</ivy-module>
if needed, restart jenkins.
and it should work now--- load http-builder in the shardlib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment