Merge pull request #199 from mq-cloudpak/tadj-1452-container-label

Add MQ build level to the container labels
This commit is contained in:
Tom Jefferson
2022-01-14 14:26:01 +00:00
committed by GitHub Enterprise
4 changed files with 82 additions and 2 deletions

View File

@@ -140,10 +140,16 @@ endif
# image tagging # image tagging
ifneq "$(RELEASE)" "$(EMPTY)" ifneq "$(RELEASE)" "$(EMPTY)"
EXTRA_LABELS=--label release=$(RELEASE) EXTRA_LABELS_RELEASE=--label "release=$(RELEASE)"
RELEASE_TAG="-$(RELEASE)" RELEASE_TAG="-$(RELEASE)"
endif 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)" ifeq "$(TIMESTAMPFLAT)" "$(EMPTY)"
TIMESTAMPFLAT=$(shell date "+%Y%m%d%H%M%S") TIMESTAMPFLAT=$(shell date "+%Y%m%d%H%M%S")
endif endif

View File

@@ -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 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 chmod +x /usr/local/bin/dep
sudo apt-get update || :
sudo apt-get install -y jq
( (
cd "$(mktemp -d)" cd "$(mktemp -d)"

View File

@@ -56,14 +56,16 @@ FILE_NAME=
BUILD_ID= BUILD_ID=
REGISTRY_HOSTNAME= REGISTRY_HOSTNAME=
FILE_LOCATION= FILE_LOCATION=
PROPERTY_NAME=
CHECK=false CHECK=false
UPLOAD=false UPLOAD=false
GET=false GET=false
GET_PROPERTY=false
DELETE=false DELETE=false
DELETE_NAMESPACE=false DELETE_NAMESPACE=false
num_commands_selected=0 num_commands_selected=0
while getopts "f:u:p:c:l:-:" flag while getopts "f:u:p:c:l:n:-:" flag
do do
case "${flag}" in case "${flag}" in
f) FILE_NAME=${OPTARG};; f) FILE_NAME=${OPTARG};;
@@ -71,6 +73,7 @@ do
p) CREDENTIAL=${OPTARG};; p) CREDENTIAL=${OPTARG};;
c) CACHE_PATH=${OPTARG};; c) CACHE_PATH=${OPTARG};;
l) FILE_LOCATION=${OPTARG};; l) FILE_LOCATION=${OPTARG};;
n) PROPERTY_NAME=${OPTARG};;
-) -)
case "${OPTARG}" in case "${OPTARG}" in
check) check)
@@ -85,6 +88,10 @@ do
GET=true GET=true
num_commands_selected=$((num_commands_selected+1)) num_commands_selected=$((num_commands_selected+1))
;; ;;
get-property)
GET_PROPERTY=true
num_commands_selected=$((num_commands_selected+1))
;;
delete) delete)
DELETE=true DELETE=true
num_commands_selected=$((num_commands_selected+1)) num_commands_selected=$((num_commands_selected+1))
@@ -167,6 +174,43 @@ if [ "$GET" == "true" ]; then
fi fi
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 if [ "$DELETE" == "true" ]; then
printf "${GREENRIGHTARROW} Checking to see if file ${FILE_NAME} exists in repository ${REMOTE_PATH} before delete\n" 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` FILE_FOUND=`curl -u ${USER}:${CREDENTIAL} -X GET "${REMOTE_PATH}/${FILE_NAME}" -o /dev/null -w "%{http_code}" -s`

View File

@@ -16,6 +16,30 @@
set -e 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 if [ "$TRAVIS_BRANCH" = "$MAIN_BRANCH" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
echo 'Retrieving global tagcache' && echo -en 'travis_fold:start:tag-cache-retrieve\\r' 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 ./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 make build-devjmstest
echo -en 'travis_fold:end:build-devjmstest\\r' echo -en 'travis_fold:end:build-devjmstest\\r'
echo 'Building Developer image...' && echo -en 'travis_fold:start:build-devserver\\r' echo 'Building Developer image...' && echo -en 'travis_fold:start:build-devserver\\r'
get_archive_level MQ_ARCHIVE_REPOSITORY_DEV
make build-devserver make build-devserver
echo -en 'travis_fold:end:build-devserver\\r' echo -en 'travis_fold:end:build-devserver\\r'
fi fi
if [ "$BUILD_ALL" = true ] || [ "$LTS" = true ] ; then if [ "$BUILD_ALL" = true ] || [ "$LTS" = true ] ; then
if [[ "$ARCH" = "amd64" || "$ARCH" = "s390x" ]] ; then if [[ "$ARCH" = "amd64" || "$ARCH" = "s390x" ]] ; then
echo 'Building Production image...' && echo -en 'travis_fold:start:build-advancedserver\\r' echo 'Building Production image...' && echo -en 'travis_fold:start:build-advancedserver\\r'
get_archive_level MQ_ARCHIVE_REPOSITORY
make build-advancedserver make build-advancedserver
echo -en 'travis_fold:end:build-advancedserver\\r' echo -en 'travis_fold:end:build-advancedserver\\r'
fi fi
@@ -45,10 +71,12 @@ else
if [[ "$BUILD_INTERNAL_LEVEL" == *".DE"* ]]; then if [[ "$BUILD_INTERNAL_LEVEL" == *".DE"* ]]; then
echo 'Building Developer image...' && echo -en 'travis_fold:start:build-devserver\\r' echo 'Building Developer image...' && echo -en 'travis_fold:start:build-devserver\\r'
get_archive_level MQ_ARCHIVE_REPOSITORY_DEV
make build-devserver make build-devserver
echo -en 'travis_fold:end:build-devserver\\r' echo -en 'travis_fold:end:build-devserver\\r'
else else
echo 'Building Production image...' && echo -en 'travis_fold:start:build-advancedserver\\r' echo 'Building Production image...' && echo -en 'travis_fold:start:build-advancedserver\\r'
get_archive_level MQ_ARCHIVE_REPOSITORY
make build-advancedserver make build-advancedserver
echo -en 'travis_fold:end:build-advancedserver\\r' echo -en 'travis_fold:end:build-advancedserver\\r'
fi fi