Commit 5c743aac authored by William Roberts's avatar William Roberts
Browse files

Test gitlab CI tags

parent 3d6d22ec
set -ex
image_url="${CI_REGISTRY_IMAGE}"
if [[ $(echo "$CI_COMMIT_TAG" | grep -E '^v[0-9]+.[0-9]+$') ]]; then
echo CI_COMMIT_TAG: "$CI_COMMIT_TAG";
docker pull "${image_url}:latest";
old_tag=$(docker run --rm "${image_url}:latest" bash -c 'echo $AERI_ARMORY_VERSION');
old_primaryv="$(echo ${old_tag%.*} | sed 's/v//')";
new_primaryv="$(echo ${CI_COMMIT_TAG%.*} | sed 's/v//')";
old_lesserv="${old_tag#*.}";
new_lesserv="${CI_COMMIT_TAG#*.}";
docker build --no-cache -f "${DOCKERFILE}" -t "${image_url}:latest" -t "${image_url}:${CI_COMMIT_TAG}" --build-arg AERI_ARMORY_VERSION="${CI_COMMIT_TAG}" ${IMAGE_DIR};
docker run --rm -v $PWD/tests:/tests "${image_url}:latest" test_suite.sh /tests;
docker push ${image_url}:${CI_COMMIT_TAG};
exit
if [[ -z "${old_tag}" ]]; then
docker push ${image_url}:latest;
elif [[ ${new_primaryv} -gt ${old_primaryv} ]]; then
docker push ${image_url}:latest;
elif [[ ${new_primaryv} -eq ${old_primaryv} ]] && [[ ${new_lesserv} -ge ${old_lesserv} ]]; then
docker push ${image_url}:latest;
fi;
fi;
# ref: https://gitlab.ssec.wisc.edu/ssec-dev/brown-bag/blob/master/.gitlab-ci.yml
# Define environment variables for all stages
variables:
# Tell docker images where the host docker daemon is
# and how to talk to it
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://docker:2375"
GIT_SUBMODULE_STRATEGY: recursive
# base template for docker-in-runner
.docker_based_job:
image: docker:19.03.13
tags:
- docker
- ssec_shared
services:
- docker:19.03.13-dind
before_script:
- docker info
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
# specialization to build an image and push back to registry with :latest and :githash versions
.build_image:
extends: .docker_based_job
variables:
DOCKERFILE: "Dockerfile"
IMAGE_NAME: ""
IMAGE_DIR: ""
stage: build image
before_script:
- docker info
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- ./.gitlab-ci.sh
stages:
- build image
# build aeri_armory when vx.x tags are pushed to master branch.
build_image:
extends: .build_image
only:
- tags
except:
- branches
variables:
IMAGE_NAME: ""
IMAGE_DIR: "."
DOCKERFILE: "Dockerfile"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment