I would like to write a little groovy-script to configure docker in my jenkins server so I can include the groovy-script to an ansible-playbook.
I found some examples how to configure maven (with the auto-installer-option) or sonarqube with groovy in jenkins. But I did not figured out how to do this for docker
Based on the things I have seen I wrote this code:
import jenkins.model.*
import hudson.plugins.*
import hudson.plugins.docker.*
import hudson.plugins.docker.model.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("hudson.plugins.docker.commons.tools.DockerTool")
and till this point the code runs without exception. But now I am facing the problem that I don't know how to set the fields like Path and Home Directory. I try it with:
def dinst = new DockerToolInstaller()
and
def sinst = new DockerInstaller()
but this only gives me a Cannot Resolve Class-Error.
I wouldn't like to start use the configuration as a code plugin for a single tool and that's why I am hoping someone here can give an hint how to configure docker in Jenkins with groovy