diff --git a/build_image.sh b/build_image.sh index adc719ea8c41..2e9ae68ad287 100755 --- a/build_image.sh +++ b/build_image.sh @@ -91,6 +91,9 @@ cp ../libcstor/src/.libs/*.so* ./docker/zfs/lib sudo docker version sudo docker build --help +curl --fail https://raw.githubusercontent.com/openebs/charts/gh-pages/scripts/release/buildscripts/push > ./docker/push +chmod +x ./docker/push + echo "Build image ${REPO_NAME}:ci with BUILD_DATE=${DBUILD_DATE}" cd docker && \ sudo docker build -f ${DOCKERFILE_BASE} -t ${REPO_NAME}:ci ${DBUILD_ARGS} . && \ diff --git a/docker/push b/docker/push deleted file mode 100755 index 80833c954e54..000000000000 --- a/docker/push +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/bash -# Copyright 2019-2020 The OpenEBS Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -if [ -z ${IMAGE_REPO} ]; -then - echo "Error: IMAGE_REPO is not specified"; - exit 1 -fi - -IMAGEID=$( sudo docker images -q ${IMAGE_REPO}:ci ) -echo $IMAGEID -if [ -z ${IMAGEID} ]; -then - echo "Error: unable to get IMAGEID for ${IMAGE_REPO}:ci"; - exit 1 -fi - -# Get an unique id based on commit and tag -BUILD_ID=$(git describe --tags --always) - -# Determine the current branch -CURRENT_BRANCH="" -if [ -z ${TRAVIS_BRANCH} ]; -then - CURRENT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2) -else - CURRENT_BRANCH=${TRAVIS_BRANCH} -fi - -#Depending on the branch where builds are generated, -# set the tag CI (fixed) and build tags. -BUILD_TAG="${CURRENT_BRANCH}-${BUILD_ID}" -CI_TAG="${CURRENT_BRANCH}-ci" -if [ ${CURRENT_BRANCH} = "develop" ]; then - CI_TAG="ci" -fi - -echo "Set the fixed ci image tag as: ${CI_TAG}" -echo "Set the build/unique image tag as: ${BUILD_TAG}" - -function TagAndPushImage() { - REPO="$1" - TAG="$2" - - #Add an option to specify a custom TAG_SUFFIX - #via environment variable. Default is no tag. - #Example suffix could be "-debug" of "-dev" - IMAGE_URI="${REPO}:${TAG}${TAG_SUFFIX}"; - sudo docker tag ${IMAGEID} ${IMAGE_URI}; - echo "Pushing ${IMAGE_URI}"; - sudo docker push ${IMAGE_URI}; -} - -if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ]; -then - sudo docker login -u "${DNAME}" -p "${DPASS}"; - - # Push CI tagged image - :ci or :branch-ci - TagAndPushImage "${IMAGE_REPO}" "${CI_TAG}" - - # Push unique tagged image - :master- or :branch- - # This unique/build image will be pushed to corresponding ci repo. - TagAndPushImage "${IMAGE_REPO}-ci" "${BUILD_TAG}" - - - 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 - # Trim the `v` from the TRAVIS_TAG if it exists - # Example: v1.10.0 maps to 1.10.0 - # Example: 1.10.0 maps to 1.10.0 - # Example: v1.10.0-custom maps to 1.10.0-custom - TagAndPushImage "${IMAGE_REPO}" "${TRAVIS_TAG#v}" - TagAndPushImage "${IMAGE_REPO}" "latest" - fi; -else - echo "No docker credentials provided. Skip uploading ${IMAGE_REPO} to docker hub"; -fi; - -# Push ci image to quay.io for security scanning -if [ ! -z "${QNAME}" ] && [ ! -z "${QPASS}" ]; -then - sudo docker login -u "${QNAME}" -p "${QPASS}" quay.io; - - # Push CI tagged image - :ci or :branch-ci - TagAndPushImage "quay.io/${IMAGE_REPO}" "${CI_TAG}" - - 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 - # Trim the `v` from the TRAVIS_TAG if it exists - TagAndPushImage "quay.io/${IMAGE_REPO}" "${TRAVIS_TAG#v}" - TagAndPushImage "quay.io/${IMAGE_REPO}" "latest" - fi; -else - echo "No docker credentials provided. Skip uploading ${IMAGE_REPO} to quay"; -fi; -#Push image to run openebs-e2e based on git commit -if [ ! -z "${GITLAB_DNAME}" ] && [ ! -z "${GITLAB_DPASS}" ] && [ ! -z "${COMMIT}" ]; -then - sudo docker login -u "${GITLAB_DNAME}" -p "${GITLAB_DPASS}"; - - # Push COMMIT tagged image - :COMMIT - TagAndPushImage "${IMAGE_REPO}" "${COMMIT}" -else - echo "No docker credentials or commit tag provided. Skip uploading openebs-e2e image"; -fi;