This might give you some idea on how to configure this. This is something
that we sort of do:

All of this is in a gradle multi-module project.

java-application
  -> jar gets dropped into an image
mqimage
  -> docker builds this too
test-project
  -> uses the gradle docker-compose plugin to orchestrate both mq and the
java service
  -> has src/test/java hit the service at a port exposed on 8080
(internally)

So, everything can build on my machine with gradle and it is isolated. Then
jenkins just has to call gradle and everything still works.

With maven you could do the same thing with a mutli-module reactor

On Fri, Sep 6, 2019 at 4:36 PM Stephen Person <stephenjamesper...@gmail.com>
wrote:

> Thanks for the reply. I'm building a camel spring standalone with
> spring-boot, built with maven, in a minimal base image. I have a junit test
> suite that is basically - drop file in directory and listen to activemq
> topic. I define the appropriate container volumes in docker-compose.yml. My
> current pipeline for jenkins goes like...
> 1. mvn clean package -DskipTests
> 2. docker build -t <image> .
> 3. mvn verify
> 4. docker push <image>
>
> This works great for one-build-at-a-time but running multiple instances in
> parallel causes chaos for my tests, so my solution was to limit the amount
> of executors for Jenkins to 1 which just isn't practical when I have many
> git branches and projects that rely on my Jenkins node.
>
> On Friday, September 6, 2019 at 3:04:40 PM UTC-4, Jan Monterrubio wrote:
>>
>> Mind clarifying a bit here:
>>
>> By isolated , do you mean something like:
>>
>> in a docker agent (jnlp pod/whatever) {
>>
>> check out your project
>> run your build
>> - the build launches containers
>> }
>>
>>
>> We use docker for isolation, so well usually have something like
>> maven/gradle build our service/app, create an image, launch a container
>> from that image, and then a test project (as part of the build) hits
>> localhost:SomePort, where some port is randomly assigned externally but
>> mapped to the containers 8080.
>>
>> Maybe it would help if you shared some details on how you build all this?
>> We are able to build both on our machines and our Jenkins with the same
>> setup.
>>
>> On Wed, Sep 4, 2019 at 22:38 Stephen Person <stephenja...@gmail.com>
>> wrote:
>>
>>> For the life of me I cannot come up with an efficient solution to
>>> running tests against a docker container in an isolated environment with
>>> Jenkins. Emphasis on 'isolated environment' so many builds/tests can run in
>>> parallel without interference. I have tried the docker-in-docker approach
>>> but this caused many complications with networking and other stuff which
>>> compromised the functionality of my containers.
>>>
>>> Some things worth mentioning...
>>> 1. I use docker-compose to build and start my container and all
>>> dependent containers (like activemq, postgres, etc)
>>> 2. Limited to using Host Network for all containers (cant use
>>> ip-forwarding)
>>>
>>> As you can tell, I think about the container as the final artifact I'm
>>> delivering to production, which is why it's important to run tests against
>>> the container instead of inside it. Any and all thought is greatly
>>> appreciated.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to jenkins...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/405a49ff-6f85-4083-92ad-f8c18a34ab5f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/405a49ff-6f85-4083-92ad-f8c18a34ab5f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/c8764e83-2c19-438d-84e0-29ac32da0862%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/c8764e83-2c19-438d-84e0-29ac32da0862%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CADgiF9L1KSYxUJfVpt%3DkxoS%2BD%2Bu9LWivQ3p_tr8dX1uw2ib%2Bog%40mail.gmail.com.

Reply via email to