Run tests inside Docker container with Jenkins -
we want give try setup ci/cd jenkins our project. project has elasticsearch , postgresql runtime dependencies , webdriver acceptance testing. in dev environment, set within 1 docker-compose.yml
file , have acceptance.sh
script run acceptance tests.
after digging documentation found it's potentially possible build ci following steps:
- dockerize project
- pull project git repo
- somehow pull
docker-compose.yml
, projectdockerfile
- either:- put in project repo
- put in separate repo (this how it's done now)
- put somewhere on server , jut copy over
- execute
docker-compose up
- project's dockerfile have
onbuilt
section run tests. unit tests run throughmix tests
, acceptance throughscripts/acceptance.sh
. it'll cool run them in parallel. - shutdown
docker-compose
, clean containers
because first experience jenkins series of questions arise:
- is viable strategy?
- how connect tests output jenkins?
- how run , shut down docker-compose?
- do need/want write pipeline that? need/want pipeline when cd on next stage?
thanks
is viable strategy?
yes is. think better include docker-compose.yml
, dockerfile
in project repo. way changes tied version of code uses changes. if it's in external repo becomes lot harder change (unless pin git sha somehow , using submodule).
project's dockerfile have
onbuild
section run tests
i avoid this. set different command run tests in container, not @ build time.
how connect tests output jenkins?
jenkins uses exit status build steps, long test script exits non-zero code on failure , 0 code on success that's need. test output printed stdout/stderr visible jenkins console.
how run , shut down docker-compose?
i recommend run compose:
docker-compose pull # if use images hub, pull latest version docker-compose --build -d
in post-build step shutdown:
docker-compose down --volumes
do need/want write pipeline that?
no, think single job fine. working simple setup first, , can figure out need split different jobs.
Comments
Post a Comment