Created
October 10, 2019 12:53
-
-
Save glance-/0137aad1e04f9e69b589de63e85206dd to your computer and use it in GitHub Desktop.
This is a nice hack to workaround a bug in docker-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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