SlaveProvider with Docker

11 views
Skip to first unread message

Stefan Schuhbäck

unread,
May 23, 2017, 12:01:35 PM5/23/17
to jenkin...@googlegroups.com
Hello,

I am trying to create a test-case for the Warnignsplugin where a
Jenkins-Slaves runs within a docker container.

It is possible to create a Slave and a docker container separately and link
these two within the test method.

However I would like to learn a bit more about Injecting such a Salve with a
SlaveProvider which would provide a complete DockerSalve without the need
setup the slave within the test itself.

The ATH already has a SshSlaveProvider however it is wired to
MultitenancyMachine via a ec2.groovy Script. I am quite new to the topic and
not sure how the process of creating such a new Provider works. I think I
would need to do the following:

1) create a DockerMachine class which implements the Machine-Interface
2) create a DockerMachineProvider class which implements the
MachineProvider-Interface. From here I need to create a DockerMachine and
include a dock container which is passed to the new Machine.
3) create a configuration which defines the necessary guice bindings such
as bind(MachineProvider.class).to(DockerMachineProvider.class) so the
the right implementation is injected.

In this process I am not sure how I would implement the Machine-Interface Methods getId(), getUser(), dir() and getNextAvailablePort().
Do I get this information from the Docker Container or do I have to provides this in some other way.

In the next step, if I can get the MachineProver running, how would I
configure the ATH to change the guice bindings only for one test.

Thanks in advance and best regards
Stefan Schuhbaeck

Jesse Glick

unread,
May 23, 2017, 12:55:10 PM5/23/17
to Jenkins Dev
I think you are looking at the wrong APIs altogether. Check out
`SshSlavesPluginTest` for an example of launching a simple agent
inside a Docker container.
Reply all
Reply to author
Forward
0 new messages