diff --git a/travis/push_image.sh b/travis/push_image.sh index a9f82f123..8c284cce9 100644 --- a/travis/push_image.sh +++ b/travis/push_image.sh @@ -4,27 +4,31 @@ check_pull_is_tagged() { if [ "${TRAVIS_TAG}" == "" ]; then return 1 else + echo "This build was started by the tag ${TRAVIS_TAG}, push image" return 0 fi } -check_branch_is_master(){ - if [ "${TRAVIS_BRANCH}" == "master" ]; then - return 0; - else - return 1; +check_release_tag() { + tag="${TRAVIS_TAG}" + if [[ "$tag" =~ ^v[0-9.]*-[0-9]{4}$ ]]; then + return 0; + else + echo "The provided tag ${tag} doesn't match that." + return 1; fi } -push_collector_image() { +push_image() { + IMAGE_VERSION=`echo ${TRAVIS_TAG:1}` docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" mvn clean package docker:build docker push skywalking/skywalking-collector:latest - docker push skywalking/skywalking-collector:${TRAVIS_TAG} + docker push skywalking/skywalking-collector:${IMAGE_VERSION} } -if check_pull_is_tagged && check_branch_is_master; then - push_collector_image +if check_pull_is_tagged && check_release_tag; then + push_image echo "Push is Done!" fi \ No newline at end of file