Skip to content

Instantly share code, notes, and snippets.

@glance-
Created October 10, 2019 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glance-/0137aad1e04f9e69b589de63e85206dd to your computer and use it in GitHub Desktop.
Save glance-/0137aad1e04f9e69b589de63e85206dd to your computer and use it in GitHub Desktop.
This is a nice hack to workaround a bug in docker-plugin
def c = com.nirima.jenkins.plugins.docker.DockerCloud.getCloudByName('Host docker')
// We're going to hack java final fields here...
import java.lang.reflect.Field
import java.lang.reflect.Modifier
for (def jt in c.getJobTemplates().values()) {
Field field = jt.getClass().getDeclaredField("instanceCap")
Field modifiersField = Field.class.getDeclaredField("modifiers")
modifiersField.setAccessible(true)
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL)
field.setAccessible(true)
field.set(jt, Integer.MAX_VALUE)
println jt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment