diff --git a/.travis.yml b/.travis.yml index 270537e..dd2dac7 100755 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,7 @@ env: - GOARCH=amd64 before_install: - sleep 15 - - sudo apt-get install -y - - sudo apt-get install -y curl - - sudo apt-get install -y shellcheck + - sudo apt-get install -y curl shellcheck jobs: include: @@ -24,7 +22,7 @@ jobs: - stage: build chaos-test images name: build docker image chaos-test script: - - make chaos-test + - make chaostest notifications: email: diff --git a/Makefile b/Makefile index 4ff8ba8..be8234c 100755 --- a/Makefile +++ b/Makefile @@ -26,11 +26,10 @@ deps: _build_check_docker _build_tests_chaostest_image: @echo "INFO: Building container image for performing chaostoolkit tests" - cd chaos-test && docker build -t litmuschaos/chaos-test . + cd chaos-test && docker build -t litmuschaos/chaostoolkit:ci . _push_tests_chaostest_image: - @echo "INFO: Publish container litmuschaos/chaos-test" - cd chaos-test/buildscripts && ./push + @echo "INFO: Publish container litmuschaos/chaostoolkit:ci" + REPONAME="litmuschaos" IMGNAME="chaostoolkit" IMGTAG="ci" ./chaos-test/buildscripts/push chaostest: deps _build_tests_chaostest_image _push_tests_chaostest_image - diff --git a/chaos-test/buildscripts/push b/chaos-test/buildscripts/push index 98c67d7..0ac3db0 100755 --- a/chaos-test/buildscripts/push +++ b/chaos-test/buildscripts/push @@ -1,14 +1,37 @@ #!/bin/bash set -e -IMAGEID=$( docker images -q litmuschaos/chaos-test ) +if [ -z "${REPONAME}" ] +then + REPONAME="litmuschaos" +fi -if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ]; +if [ -z "${IMGNAME}" ] || [ -z "${IMGTAG}" ]; then - docker login -u "${DNAME}" -p "${DPASS}"; - #Push to docker hub repository with latest tag - docker tag ${IMAGEID} litmuschaos/chaos-test:latest - docker push litmuschaos/chaos-test:latest; + echo "Image details are missing. Nothing to push."; + exit 1 +fi + +IIMAGEID=$( sudo docker images -q ${REPONAME}/${IMGNAME}:${IMGTAG} ) + +if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ]; +then + sudo docker login -u "${DNAME}" -p "${DPASS}"; + # Push image to docker hub + echo "Pushing ${REPONAME}/${IMGNAME}:${IMGTAG} ..."; + sudo docker push ${REPONAME}/${IMGNAME}:${IMGTAG} ; + if [ ! -z "${TRAVIS_TAG}" ] ; + then + # Push with different tags if tagged as a release + # When github is tagged with a release, then Travis will + # set the release tag in env TRAVIS_TAG + echo "Pushing ${REPONAME}/${IMGNAME}:${TRAVIS_TAG} ..."; + sudo docker tag ${IMAGEID} ${REPONAME}/${IMGNAME}:${TRAVIS_TAG} + sudo docker push ${REPONAME}/${IMGNAME}:${TRAVIS_TAG}; + echo "Pushing ${REPONAME}/${IMGNAME}:latest ..."; + sudo docker tag ${IMAGEID} ${REPONAME}/${IMGNAME}:latest + sudo docker push ${REPONAME}/${IMGNAME}:latest; + fi; else - echo "No docker credentials provided. Skip uploading litmuschaos/chaostest:latest to docker hub"; + echo "No docker credentials provided. Skip uploading ${REPONAME}/${IMGNAME}:${IMGTAG} to docker hub"; fi;