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:

  1. dockerize project
  2. pull project git repo
  3. somehow pull docker-compose.yml , project dockerfile - either:
    • put in project repo
    • put in separate repo (this how it's done now)
    • put somewhere on server , jut copy over
  4. execute docker-compose up
  5. project's dockerfile have onbuilt section run tests. unit tests run through mix tests , acceptance through scripts/acceptance.sh. it'll cool run them in parallel.
  6. 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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -