Merge pull request #199 from mq-cloudpak/tadj-1452-container-label
Add MQ build level to the container labels
This commit is contained in:
8
Makefile
8
Makefile
@@ -140,10 +140,16 @@ endif
|
||||
# image tagging
|
||||
|
||||
ifneq "$(RELEASE)" "$(EMPTY)"
|
||||
EXTRA_LABELS=--label release=$(RELEASE)
|
||||
EXTRA_LABELS_RELEASE=--label "release=$(RELEASE)"
|
||||
RELEASE_TAG="-$(RELEASE)"
|
||||
endif
|
||||
|
||||
ifneq "$(MQ_ARCHIVE_LEVEL)" "$(EMPTY)"
|
||||
EXTRA_LABELS_LEVEL=--label "mq-build=$(MQ_ARCHIVE_LEVEL)"
|
||||
endif
|
||||
|
||||
EXTRA_LABELS=$(EXTRA_LABELS_RELEASE) $(EXTRA_LABELS_LEVEL)
|
||||
|
||||
ifeq "$(TIMESTAMPFLAT)" "$(EMPTY)"
|
||||
TIMESTAMPFLAT=$(shell date "+%Y%m%d%H%M%S")
|
||||
endif
|
||||
|
||||
@@ -21,6 +21,8 @@ set -ex
|
||||
|
||||
sudo curl -Lo /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.5.1/dep-linux-$ARCH
|
||||
sudo chmod +x /usr/local/bin/dep
|
||||
sudo apt-get update || :
|
||||
sudo apt-get install -y jq
|
||||
|
||||
(
|
||||
cd "$(mktemp -d)"
|
||||
|
||||
@@ -56,14 +56,16 @@ FILE_NAME=
|
||||
BUILD_ID=
|
||||
REGISTRY_HOSTNAME=
|
||||
FILE_LOCATION=
|
||||
PROPERTY_NAME=
|
||||
|
||||
CHECK=false
|
||||
UPLOAD=false
|
||||
GET=false
|
||||
GET_PROPERTY=false
|
||||
DELETE=false
|
||||
DELETE_NAMESPACE=false
|
||||
num_commands_selected=0
|
||||
while getopts "f:u:p:c:l:-:" flag
|
||||
while getopts "f:u:p:c:l:n:-:" flag
|
||||
do
|
||||
case "${flag}" in
|
||||
f) FILE_NAME=${OPTARG};;
|
||||
@@ -71,6 +73,7 @@ do
|
||||
p) CREDENTIAL=${OPTARG};;
|
||||
c) CACHE_PATH=${OPTARG};;
|
||||
l) FILE_LOCATION=${OPTARG};;
|
||||
n) PROPERTY_NAME=${OPTARG};;
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
check)
|
||||
@@ -85,6 +88,10 @@ do
|
||||
GET=true
|
||||
num_commands_selected=$((num_commands_selected+1))
|
||||
;;
|
||||
get-property)
|
||||
GET_PROPERTY=true
|
||||
num_commands_selected=$((num_commands_selected+1))
|
||||
;;
|
||||
delete)
|
||||
DELETE=true
|
||||
num_commands_selected=$((num_commands_selected+1))
|
||||
@@ -167,6 +174,43 @@ if [ "$GET" == "true" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$GET_PROPERTY" == "true" ]; then
|
||||
if [[ -z $PROPERTY_NAME ]]; then
|
||||
printf "${REDCROSS} Property name to retrieve from '${FILE_NAME}' was not supplied please do so\n"
|
||||
printf $SPACER
|
||||
printf "${ERROR}$usage${END}\n"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z $FILE_LOCATION ]]; then
|
||||
printf "${REDCROSS} File location to store property value in was not supplied please do so\n"
|
||||
printf $SPACER
|
||||
printf "${ERROR}$usage${END}\n"
|
||||
exit 1
|
||||
fi
|
||||
printf "${GREENRIGHTARROW} Attempting to retrieve ${PROPERTY_NAME} of ${FILE_NAME} from repository ${REMOTE_PATH} and store it in ${FILE_LOCATION}\n"
|
||||
|
||||
query_url="${FILE_NAME}"
|
||||
query_url="${query_url/\/artifactory\//\/artifactory\/api\/storage\//}?properties=${PROPERTY_NAME}"
|
||||
request_result="$(curl -s -u ${USER}:${CREDENTIAL} "${query_url}")"
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
printf "Unable to retrieve properties from ${query_url}"
|
||||
exit 1
|
||||
else
|
||||
printf "${GREENTICK} Properties retrieved from ${query_url}"
|
||||
fi
|
||||
|
||||
jq -r '.properties.snapshot|first' <<<"$request_result" > ${FILE_LOCATION}
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
printf "Unable to write snapshot property to ${FILE_LOCATION}"
|
||||
exit 1
|
||||
else
|
||||
printf "${GREENTICK} Property written to ${FILE_LOCATION}"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ "$DELETE" == "true" ]; then
|
||||
printf "${GREENRIGHTARROW} Checking to see if file ${FILE_NAME} exists in repository ${REMOTE_PATH} before delete\n"
|
||||
FILE_FOUND=`curl -u ${USER}:${CREDENTIAL} -X GET "${REMOTE_PATH}/${FILE_NAME}" -o /dev/null -w "%{http_code}" -s`
|
||||
|
||||
@@ -16,6 +16,30 @@
|
||||
|
||||
set -e
|
||||
|
||||
archive_level_cache_dir="$(mktemp -d)"
|
||||
|
||||
get_archive_level() {
|
||||
local level_path
|
||||
local archive_variable
|
||||
archive_variable="$1"
|
||||
MQ_ARCHIVE_LEVEL=""
|
||||
level_path="${archive_level_cache_dir}/${archive_variable}.level"
|
||||
|
||||
if [[ ! -f "$level_path" ]]; then
|
||||
if [[ -z "${REPOSITORY_USER}" || -z "${REPOSITORY_CREDENTIAL}" ]]; then
|
||||
echo 'Skipping level lookup as repository credentials not set'
|
||||
return
|
||||
fi
|
||||
if [[ -z "${!archive_variable}" ]]; then
|
||||
echo "Skipping level lookup as '\$${archive_variable}' is not set"
|
||||
return
|
||||
fi
|
||||
./travis-build-scripts/artifact-util.sh -f "${!archive_variable}" -u "${REPOSITORY_USER}" -p "${REPOSITORY_CREDENTIAL}" -l "$level_path" -n snapshot --get-property
|
||||
fi
|
||||
read -r MQ_ARCHIVE_LEVEL < "$level_path"
|
||||
export MQ_ARCHIVE_LEVEL
|
||||
}
|
||||
|
||||
if [ "$TRAVIS_BRANCH" = "$MAIN_BRANCH" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
|
||||
echo 'Retrieving global tagcache' && echo -en 'travis_fold:start:tag-cache-retrieve\\r'
|
||||
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} -f cache/${TAGCACHE_FILE} -l ./.tagcache --check
|
||||
@@ -28,12 +52,14 @@ if [ -z "$BUILD_INTERNAL_LEVEL" ] ; then
|
||||
make build-devjmstest
|
||||
echo -en 'travis_fold:end:build-devjmstest\\r'
|
||||
echo 'Building Developer image...' && echo -en 'travis_fold:start:build-devserver\\r'
|
||||
get_archive_level MQ_ARCHIVE_REPOSITORY_DEV
|
||||
make build-devserver
|
||||
echo -en 'travis_fold:end:build-devserver\\r'
|
||||
fi
|
||||
if [ "$BUILD_ALL" = true ] || [ "$LTS" = true ] ; then
|
||||
if [[ "$ARCH" = "amd64" || "$ARCH" = "s390x" ]] ; then
|
||||
echo 'Building Production image...' && echo -en 'travis_fold:start:build-advancedserver\\r'
|
||||
get_archive_level MQ_ARCHIVE_REPOSITORY
|
||||
make build-advancedserver
|
||||
echo -en 'travis_fold:end:build-advancedserver\\r'
|
||||
fi
|
||||
@@ -45,10 +71,12 @@ else
|
||||
|
||||
if [[ "$BUILD_INTERNAL_LEVEL" == *".DE"* ]]; then
|
||||
echo 'Building Developer image...' && echo -en 'travis_fold:start:build-devserver\\r'
|
||||
get_archive_level MQ_ARCHIVE_REPOSITORY_DEV
|
||||
make build-devserver
|
||||
echo -en 'travis_fold:end:build-devserver\\r'
|
||||
else
|
||||
echo 'Building Production image...' && echo -en 'travis_fold:start:build-advancedserver\\r'
|
||||
get_archive_level MQ_ARCHIVE_REPOSITORY
|
||||
make build-advancedserver
|
||||
echo -en 'travis_fold:end:build-advancedserver\\r'
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user