first commit

This commit is contained in:
2024-10-28 23:04:48 +01:00
commit 1ee55157f1
911 changed files with 325331 additions and 0 deletions

View File

@@ -0,0 +1,249 @@
#!/bin/bash
# © Copyright IBM Corporation 2020
#
# 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.
usage="
Usage: artifact-util.sh -c my-registry.com/artifacts/my-project/builds/123 -u me@org.com -p top-secret -f tagcache -l ./.tagcache --upload \"
Where:
-c - Full artifact destination hostname and path
-u - The username to access repository
-p - The password or api-key to access repository
-f - Name of the file in repository
-l - The path and name to the file whose contents is to be pushed or retrieved into
Then one action of either
--check - Check if the file exists
--upload - Upload the contents of a file [-l must be specified]
--get - Get a file and write to a local file [-l must be specified]
--delete - Delet the remote file from repository
"
GREEN="\033[32m"
RED="\033[31m"
END="\033[0m"
RIGHTARROW="\xE2\x96\xB6"
BLUERIGHTARROW=${BLUE}${RIGHTARROW}${END}
GREENRIGHTARROW=${GREEN}${RIGHTARROW}${END}
ERROR=${RED}
TICK="\xE2\x9C\x94"
CROSS="\xE2\x9C\x97"
GREENTICK=${GREEN}${TICK}${END}
REDCROSS=${RED}${CROSS}${END}
SPACER="\n\n"
USER=
CREDENTIAL=
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:n:-:" flag
do
case "${flag}" in
f) FILE_NAME=${OPTARG};;
u) USER=${OPTARG};;
p) CREDENTIAL=${OPTARG};;
c) CACHE_PATH=${OPTARG};;
l) FILE_LOCATION=${OPTARG};;
n) PROPERTY_NAME=${OPTARG};;
-)
case "${OPTARG}" in
check)
CHECK=true
num_commands_selected=$((num_commands_selected+1))
;;
upload)
UPLOAD=true
num_commands_selected=$((num_commands_selected+1))
;;
get)
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))
;;
delete-namespace)
DELETE_NAMESPACE=true
num_commands_selected=$((num_commands_selected+1))
;;
*)
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
echo "Unknown option --${OPTARG}" >&2
fi
;;
esac;;
esac
done
if [[ $num_commands_selected == 0 || $num_commands_selected -gt 1 ]]; then
printf "${REDCROSS} ${ERROR}Too many actions specified. Should be one of ${END}--check${ERROR},${END} --get${ERROR},${END} --upload${ERROR} or${END} --delete${ERROR}!${END}\n"
printf $SPACER
printf "${ERROR}$usage${END}\n"
exit 1
fi
if [ "$DELETE_NAMESPACE" != "true" ]; then
if [[ -z $CACHE_PATH|| -z $USER || -z $CREDENTIAL || -z $FILE_NAME ]] ; then
printf "${REDCROSS} ${ERROR}Missing parameter!${END}\n"
printf "Cache Path:"$CACHE_PATH"\n"
printf "File name:"$FILE_NAME"\n"
printf "User":$USER"\n"
printf $SPACER
printf "${ERROR}$usage${END}\n"
exit 1
fi
fi
REMOTE_PATH="https://${CACHE_PATH}/$TRAVIS_BUILD_ID"
if [ "$CHECK" == "true" ]; then
printf "${GREENRIGHTARROW} Checking to see if file ${FILE_NAME} exists in repository ${REMOTE_PATH}\n"
FILE_FOUND=`curl -u ${USER}:${CREDENTIAL} -X GET "${REMOTE_PATH}/${FILE_NAME}" -o /dev/null -w "%{http_code}" -s`
if [ "$FILE_FOUND" != "200" ]; then
printf "${REDCROSS} File ${FILE_NAME} was not found\n"
exit 1
else
printf "${GREENTICK} File ${FILE_NAME} was found\n"
fi
fi
if [ "$UPLOAD" == "true" ]; then
printf "${GREENRIGHTARROW} Attempting to upload the file ${FILE_NAME} to repository ${REMOTE_PATH}\n"
if [[ -z $FILE_LOCATION ]]; then
printf "${REDCROSS} Location for ${FILE_NAME} was not supplied please do so\n"
printf $SPACER
printf "${ERROR}$usage${END}\n"
exit 1
fi
if [ ! -f "$FILE_LOCATION" ]; then
printf "${REDCROSS} Location supplied ${FILE_LOCATION } for file ${FILE_NAME} did not resolve to a file with contents to upload\n"
printf $SPACER
printf "${ERROR}$usage${END}\n"
exit 1
fi
curl -u ${USER}:${CREDENTIAL} -X PUT "$REMOTE_PATH/${FILE_NAME}" -T ${FILE_LOCATION}
fi
if [ "$GET" == "true" ]; then
printf "${GREENRIGHTARROW} Attempting to download file ${FILE_NAME} from repository ${REMOTE_PATH} to ${FILE_LOCATION}\n"
if [[ -z $FILE_LOCATION ]]; then
printf "${REDCROSS} Location for ${FILE_NAME} was not supplied please do so\n"
printf $SPACER
printf "${ERROR}$usage${END}\n"
exit 1
fi
curl -u ${USER}:${CREDENTIAL} "$REMOTE_PATH/${FILE_NAME}" -o ${FILE_LOCATION} -s
if [ $? != 0 ]; then
printf "${REDCROSS} Failed download\n"
else
printf "${GREENTICK} File ${FILE_NAME} was downloaded to ${FILE_LOCATION}\n"
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`
if [ "$FILE_FOUND" != "200" ]; then
printf "${REDCROSS} File ${FILE_NAME} was not found to delete\n"
exit 1
else
printf "${GREENTICK} File ${FILE_NAME} was found\n"
printf "${GREENRIGHTARROW} Attempting the delete of ${REMOTE_PATH}/${FILE_NAME}"
curl -u ${USER}:${CREDENTIAL} -X DELETE "${REMOTE_PATH}/${FILE_NAME}" -s
if [ $? != 0 ]; then
printf "${REDCROSS} Failed delete\n"
else
printf "${GREENTICK} File ${FILE_NAME} was deleted from "${REMOTE_PATH}"\n"
fi
fi
fi
if [ "$DELETE_NAMESPACE" == "true" ]; then
printf "${GREENRIGHTARROW} Checking to see if repository ${REMOTE_PATH} exists before delete\n"
DIR_FOUND=`curl -u ${USER}:${CREDENTIAL} -X GET "${REMOTE_PATH}" -o /dev/null -w "%{http_code}" -s`
if [ "$DIR_FOUND" != "200" ]; then
printf "${REDCROSS} Namespace ${REMOTE_PATH} was not found to delete\n"
exit 1
else
printf "${GREENTICK} Namespace ${REMOTE_PATH} was found\n"
printf "${GREENRIGHTARROW} Attempting the delete of ${REMOTE_PATH}"
curl -u ${USER}:${CREDENTIAL} -X DELETE "${REMOTE_PATH}" -s
if [ $? != 0 ]; then
printf "${REDCROSS} Failed delete\n"
else
printf "${GREENTICK} Namespace ${REMOTE_PATH} deleted \n"
fi
fi
fi
exit 0

84
travis-build-scripts/build.sh Executable file
View File

@@ -0,0 +1,84 @@
#!/bin/bash
# © Copyright IBM Corporation 2019, 2020
#
# 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
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") || "$TRAVIS_BRANCH" == ifix* ]]; 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
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} -f cache/${TAGCACHE_FILE} -l ./.tagcache --get
echo -en 'travis_fold:end:tag-cache-retrieve\\r'
fi
if [ -z "$BUILD_INTERNAL_LEVEL" ] ; then
if [ "$LTS" != true ] ; then
echo 'Building Developer JMS test image...' && echo -en 'travis_fold:start:build-devjmstest\\r'
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" || "$ARCH" = "ppc64le" ]] ; 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
fi
else
echo 'Building Developer JMS test image...' && echo -en 'travis_fold:start:build-devjmstest\\r'
make build-devjmstest
echo -en 'travis_fold:end:build-devjmstest\\r'
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
fi

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# © Copyright IBM Corporation 2020
#
# 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.
echo 'Cleaning up remote cache' && echo -en 'travis_fold:start:cleanup\\r'
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} -f cache/${TAGCACHE_FILE} --delete
echo -en 'travis_fold:end:cleanup\\r'

View File

@@ -0,0 +1,152 @@
#!/bin/bash
# © Copyright IBM Corporation 2024
#
# 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
BINPATH="/usr/local/bin/"
CV_YQ_VERSION=3.3.2
echo "Installing yq..."
curl -LO "https://github.com/mikefarah/yq/releases/download/$CV_YQ_VERSION/yq_linux_amd64"
chmod +x yq_linux_amd64
sudo mv yq_linux_amd64 ${BINPATH}/yq
usage="
Usage: create-image-manifest.sh -f image-manifest.yaml
Where:
-f - The file name to use
"
GREEN="\033[32m"
RED="\033[31m"
BLUE="\033[34m"
PURPLE="\033[35m"
AQUA="\033[36m"
END="\033[0m"
UNDERLINE="\033[4m"
BOLD="\033[1m"
ITALIC="\033[3m"
TITLE="\n"${BLUE}${BOLD}${UNDERLINE}
STEPTITLE=${BLUERIGHTARROW}" "${BOLD}${ITALIC}
SUBSTEPTITLE=${MINIARROW}${MINIARROW}${MINIARROW}" "${ITALIC}
RIGHTARROW="\xE2\x96\xB6"
MINIARROW="\xE2\x96\xBB"
BLUERIGHTARROW=${BLUE}${RIGHTARROW}${END}
GREENRIGHTARROW=${GREEN}${RIGHTARROW}${END}
ERROR=${RED}
TICK="\xE2\x9C\x94"
CROSS="\xE2\x9C\x97"
GREENTICK=${GREEN}${TICK}${END}
REDCROSS=${RED}${CROSS}${END}
SPACER="\n\n"
MQ_VERSION_TAG=
REGISTRY_USER=
REGISTRY_CREDENTIAL=
REGISTRY_HOSTNAME=
REGISTRY_NAMESPACE=
MQ_IMAGE_DEVSERVER_AMD64_DIGEST=
MQ_IMAGE_DEVSERVER_S390X_DIGEST=
MQ_IMAGE_DEVSERVER_PPC64LE_DIGEST=
MANIFEST_SHA_DEV=
MQ_IMAGE_ADVANCEDSERVER_AMD64_DIGEST=
MQ_IMAGE_ADVANCEDSERVER_S390X_DIGEST=
MQ_IMAGE_ADVANCEDSERVER_PPC64LE_DIGEST=
MANIFEST_SHA_ADV=
while getopts f:o:t:u:p:r:n:a:m:s: flag
do
case "${flag}" in
f) IMAGE_MANIFEST_FILE=${OPTARG};;
o) MQ_VERSION_TAG=${OPTARG};;
t) MQ_IMAGE_DEVSERVER_AMD64_DIGEST=${OPTARG};;
u) MQ_IMAGE_DEVSERVER_S390X_DIGEST=${OPTARG};;
p) MQ_IMAGE_DEVSERVER_PPC64LE_DIGEST=${OPTARG};;
r) MANIFEST_SHA_DEV=${OPTARG};;
n) MQ_IMAGE_ADVANCEDSERVER_AMD64_DIGEST=${OPTARG};;
a) MQ_IMAGE_ADVANCEDSERVER_S390X_DIGEST=${OPTARG};;
m) MQ_IMAGE_ADVANCEDSERVER_PPC64LE_DIGEST=${OPTARG};;
s) MANIFEST_SHA_ADV=${OPTARG};;
esac
done
MQ_TAG_REMOVED_DOT=$(echo "$MQ_VERSION_TAG" | awk -F'[.-]' '{print $1 "_" $2 "_" $3 "_" $4 "_" $5}')
MQ_VERSION=$(echo "$MQ_VERSION_TAG" | awk -F'[.-]' '{print $1 "." $2 "." $3 "." $4 "-" $5}')
PRODUCTION_TAG="${MQ_VERSION}-${APAR_NUMBER}-${FIX_NUMBER}"
if [[ -z $IMAGE_MANIFEST_FILE ]] ; then
printf "${REDCROSS} ${ERROR}You must specify a filename${END}\n"
printf "${ERROR}$usage${END}\n"
exit 1
fi
DIR_PATH=$(dirname "$IMAGE_MANIFEST_FILE")
# Create the directory if it does not exist
if [ ! -d "$DIR_PATH" ]; then
echo "Directory does not exist. Creating directory: $DIR_PATH"
mkdir -p "$DIR_PATH"
# Check if the directory creation succeeded
if [ $? -ne 0 ]; then
echo "Failed to create directory: $DIR_PATH"
exit 1
fi
fi
rm -f $IMAGE_MANIFEST_FILE
touch $IMAGE_MANIFEST_FILE
DATE_STAMP=`date --utc '+%Y-%m-%dT%H:%M:%S.%3N%Z' 2>&1` || EXIT_CODE=$?
if [ "${EXIT_CODE}" != "0" ]; then
DATE_STAMP=`date -u '+%Y-%m-%dT%H:%M:%S%Z'`
fi
echo "Generating build manifest process started"
yq write -i $IMAGE_MANIFEST_FILE metadata.createdAt $DATE_STAMP
yq write -i $IMAGE_MANIFEST_FILE metadata.commitId $TRAVIS_COMMIT
yq write -i $IMAGE_MANIFEST_FILE metadata.travisBuildId $TRAVIS_BUILD_ID
yq write -i $IMAGE_MANIFEST_FILE metadata.travisBuildUrl $TRAVIS_BUILD_WEB_URL
yq write -i $IMAGE_MANIFEST_FILE metadata.stage dev_ifix
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.name ibm-mqadvanced-server
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.productionName ibm-mqadvanced-server
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.productionTag $PRODUCTION_TAG
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.tag $MQ_VERSION_TAG
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.digests.amd64 $MQ_IMAGE_ADVANCEDSERVER_AMD64_DIGEST
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.digests.s390x $MQ_IMAGE_ADVANCEDSERVER_S390X_DIGEST
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.digests.ppc64le $MQ_IMAGE_ADVANCEDSERVER_PPC64LE_DIGEST
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServer.digests.fatManifest $MANIFEST_SHA_ADV
if [ "$PROMOTE_DEVELOPER_IMAGE_IFIX" = true ]; then
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.name ibm-mqadvanced-server-dev
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.productionName mq
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.productionTag $PRODUCTION_TAG
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.tag $MQ_VERSION_TAG
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.digests.amd64 $MQ_IMAGE_DEVSERVER_AMD64_DIGEST
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.digests.s390x $MQ_IMAGE_DEVSERVER_S390X_DIGEST
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.digests.ppc64le $MQ_IMAGE_DEVSERVER_PPC64LE_DIGEST
yq write -i $IMAGE_MANIFEST_FILE images.operands.mq.${MQ_TAG_REMOVED_DOT}.ibmMQAdvancedServerDev.digests.fatManifest $MANIFEST_SHA_DEV
fi
echo "Generating build manifest process completed"

View File

@@ -0,0 +1,90 @@
#!/bin/bash
# © Copyright IBM Corporation 2020
#
# 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
usage="
Usage: create-image-manifest.sh -r hyc-mq-container-team-docker-local.artifactory.swg-devops.com -n foo -i ibm-mqadvanced-server-dev -t test -d \"sha256:038ad492532b099c324b897ce9da31ae0be312a1d0063f6456f2e3143cc4f4b8 sha256:754f466cf2cfc5183ac705689ce6720f27fecd07c97970ba3ec48769acba067d\"
Where:
-r - The image registry hostname
-n - The image registry namespace
-i - The image name
-t - The desired top level manifest tag
-d - A space separated list of sha256 image digests to be included
"
GREEN="\033[32m"
RED="\033[31m"
BLUE="\033[34m"
PURPLE="\033[35m"
AQUA="\033[36m"
END="\033[0m"
UNDERLINE="\033[4m"
BOLD="\033[1m"
ITALIC="\033[3m"
TITLE=${BLUE}${BOLD}${UNDERLINE}
STEPTITLE=${BLUERIGHTARROW}" "${BOLD}${ITALIC}
SUBSTEPTITLE=${MINIARROW}${MINIARROW}${MINIARROW}" "${ITALIC}
RIGHTARROW="\xE2\x96\xB6"
MINIARROW="\xE2\x96\xBB"
BLUERIGHTARROW=${BLUE}${RIGHTARROW}${END}
GREENRIGHTARROW=${GREEN}${RIGHTARROW}${END}
ERROR=${RED}
TICK="\xE2\x9C\x94"
CROSS="\xE2\x9C\x97"
GREENTICK=${GREEN}${TICK}${END}
REDCROSS=${RED}${CROSS}${END}
SPACER="\n\n"
while getopts r:n:i:t:d:h:u:p: flag
do
case "${flag}" in
r) REGISTRY=${OPTARG};;
n) NAMESPACE=${OPTARG};;
i) IMAGE=${OPTARG};;
t) TAG=${OPTARG};;
d) DIGESTS=${OPTARG};;
u) USER=${OPTARG};;
p) CREDENTIAL=${OPTARG};;
esac
done
if [[ -z $REGISTRY || -z $NAMESPACE || -z $IMAGE || -z $TAG || -z $DIGESTS ]] ; then
printf "${REDCROSS} ${ERROR}Missing parameter!${END}\n"
printf "${ERROR}$usage${END}\n"
exit 1
fi
# Docker CLI manifest commands require experimental features to be turned on
export DOCKER_CLI_EXPERIMENTAL=enabled
MANIFESTS=""
for digest in $DIGESTS ; do \
MANIFESTS+=" $REGISTRY/$NAMESPACE/$IMAGE@$digest"
done
docker login $REGISTRY -u $USER -p $CREDENTIAL
docker manifest create $REGISTRY/$NAMESPACE/$IMAGE:$TAG $MANIFESTS
MANIFEST_DIGEST=$(docker manifest push --purge $REGISTRY/$NAMESPACE/$IMAGE:$TAG)
echo $MANIFEST_DIGEST

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# © Copyright IBM Corporation 2020
#
# 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
echo 'Cacheing MQ tag...' && echo -en 'travis_fold:start:build-cache-mq-tag\\r'
make cache-mq-tag
echo -en 'travis_fold:end:cache-mq-tag\\r'
echo 'Caching tagcache for future stages' && echo -en 'travis_fold:start:tag-cache\\r'
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} -f cache/${TAGCACHE_FILE} -l ./.tagcache --upload
echo -en 'travis_fold:end:tag-cache\\r'

View File

@@ -0,0 +1,56 @@
#!/bin/bash
# © Copyright IBM Corporation 2024
#
# 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
GREEN="\033[32m"
RED="\033[31m"
END="\033[0m"
RIGHTARROW="\xE2\x96\xB6"
BLUERIGHTARROW=${BLUE}${RIGHTARROW}${END}
GREENRIGHTARROW=${GREEN}${RIGHTARROW}${END}
ERROR=${RED}
TICK="\xE2\x9C\x94"
CROSS="\xE2\x9C\x97"
GREENTICK=${GREEN}${TICK}${END}
REDCROSS=${RED}${CROSS}${END}
printf "${GREENRIGHTARROW} Checking to see if mq build folder ${MQ_SNAPSHOT_NAME} exists in repository ${IFIX_BASE_MQ_DRIVER_ARCHIVE_REPOSITORY}\n"
REMOTE_PATH="${IFIX_BASE_MQ_DRIVER_ARCHIVE_REPOSITORY}/${MQ_SNAPSHOT_NAME}"
FILE_FOUND=$(curl -u "${REPOSITORY_USER}:${REPOSITORY_CREDENTIAL}" -L -X GET "${REMOTE_PATH}" -o /dev/null -w "%{http_code}" -s)
if [ "$FILE_FOUND" -eq 200 ]; then
printf "${GREENTICK} Build Folder ${MQ_SNAPSHOT_NAME} was found in path ${REMOTE_PATH} \n"
elif [ "$FILE_FOUND" -eq 404 ]; then
printf "${REDCROSS} Folder ${MQ_SNAPSHOT_NAME} was not found\n"
mkdir -p tmp
git clone git@github.ibm.com:mq-cloudpak/pipeline-scripts.git
cd pipeline-scripts/store-base-ifix-driver
chmod +x store-base-ifix-driver.sh
./store-base-ifix-driver.sh
else
echo "Unexpected HTTP status code: $FILE_FOUND"
exit 1
fi
echo "Check and upload base MQ driver process completed."

View File

@@ -0,0 +1,65 @@
#!/bin/bash
# -*- mode: sh -*-
# © Copyright IBM Corporation 2020, 2023
#
#
# 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.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
sudo add-apt-repository "deb [arch=$ARCH] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt -y install docker-ce pass
echo "default-cache-ttl 1200" > /home/travis/.gnupg/gpg-agent.conf
gpg-connect-agent reloadagent /bye
mkdir -p $GOPATH/src/github.com/docker
cd $GOPATH/src/github.com/docker
git clone https://github.com/docker/docker-credential-helpers
cd docker-credential-helpers
# After https://github.com/docker/docker-credential-helpers/commit/fd0197473f0ecb29e73ccef9028057194ff463bc go 1.18 is required... Pin commit if earlier go installed
go_version="$(go version | cut -f3 -d' ')"
IFS=. read -a go_version_parts <<<"$go_version"
go_major="${go_version_parts[0]##go}"
go_minor="${go_version_parts[1]}"
if [[ "$go_major" -eq 1 && "$go_minor" -lt 18 ]]; then
echo "Go version ${go_major}.${go_minor} < 1.18... Pinning credential-helper commit"
git checkout ab7fd12c67d83193072fa91e5648b036547f6323
make pass
cp bin/docker-credential-pass $GOPATH/bin/docker-credential-pass
else
make pass
cp bin/build/docker-credential-pass $GOPATH/bin/docker-credential-pass
fi
mkdir -p /home/travis/.docker
echo '{ "credsStore": "pass" }' | tee /home/travis/.docker/config.json
gpg2 --batch --gen-key <<-EOF
%echo generating a standard key
Key-Type: DSA
Key-Length: 1024
Subkey-Type: ELG-E
Subkey-Length: 1024
Name-Real: Travis CI
Name-Email: travis@osism.io
Expire-Date: 0
Passphrase: $REGISTRY_PASS
%commit
%echo done
EOF
key=$(gpg2 --list-secret-keys | grep uid -B 1 | head -n 1 | sed 's/^ *//g')
pass init $key
pass insert docker-credential-helpers/docker-pass-initialized-check <<-EOF
pass is initialized
pass is initialized
EOF
gpg2 --passphrase $REGISTRY_PASS --pinentry-mode=loopback --output doc --decrypt ~/.password-store/docker-credential-helpers/docker-pass-initialized-check.gpg

View File

@@ -0,0 +1,41 @@
#!/bin/bash
# © Copyright IBM Corporation 2019, 2024
#
# 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
GREEN="\033[32m"
END="\033[0m"
RIGHTARROW="\xE2\x96\xB6"
GREENRIGHTARROW=${GREEN}${RIGHTARROW}${END}
echo "MQ_SNAPSHOT_NAME=$MQ_SNAPSHOT_NAME"
echo "APAR_NUMBER=$APAR_NUMBER"
echo "started manifest sync operation with ifix stage branch"
printf ${GREENRIGHTARROW}" Installing pipeline-util\n"
mkdir -p $GOPATH/src/github.ibm.com/mq-cloudpak
git clone git@github.ibm.com:mq-cloudpak/pipeline-util.git "$GOPATH/src/github.ibm.com/mq-cloudpak/pipeline-util"
cd "$GOPATH/src/github.ibm.com/mq-cloudpak/pipeline-util"
make install
echo 'Sync with linked stage branch for ifix ...' && echo -en 'travis_fold:start:sync-latest\\r'
pipeline-util stages sync --stage=dev-ifix --mq-snapshot-name=${MQ_SNAPSHOT_NAME} --apar-number=${APAR_NUMBER} --sync-branch-name=${TRAVIS_BRANCH} --sync-repository-name=mq-container --promotion-type=IFIX --travis-token=${TRAVIS_TOKEN}
echo -en 'travis_fold:end:sync-latest\\r'

54
travis-build-scripts/push.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
# © Copyright IBM Corporation 2019, 2021
#
# 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 [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Not pushing as we are a pull request"
exit 0
fi
if [ ! -z $2 ]; then
export ARCH=$2
fi
function push_developer {
echo 'Pushing Developer image...' && echo -en 'travis_fold:start:push-devserver\\r'
make push-devserver
echo -en 'travis_fold:end:push-devserver\\r'
}
function push_production {
echo 'Pushing Production image...' && echo -en 'travis_fold:start:push-advancedserver\\r'
make push-advancedserver
echo -en 'travis_fold:end:push-advancedserver\\r'
}
# call relevant push function
if [ ! -z $1 ]; then
case "$1" in
developer) push_developer
;;
production) push_production
;;
*) echo "ERROR: Type ( developer | production ) must be passed to push.sh"
exit 1
;;
esac
else
echo "ERROR: Type ( developer | production ) must be passed to push.sh"
exit 1
fi

70
travis-build-scripts/run.sh Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
# © Copyright IBM Corporation 2019, 2020
#
# 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 [ "$(uname -m)" = "x86_64" ] ; then export ARCH="amd64" ; else export ARCH=$(uname -m) ; fi
# if DOCKER_USER is set, authenticate with docker.io to mitigate rate limit (https://www.docker.com/increase-rate-limits)
if [ -n "$DOCKER_USER" ] ; then echo 'Authenticating with docker.io...' && docker login -u $DOCKER_USER -p $DOCKER_PASS docker.io ; fi
if [ "$PUSH_MANIFEST_ONLY" = true ] ; then
echo 'Retrieving remote tagcache' && echo -en 'travis_fold:start:retrieve-tag-cache\\r'
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} -f cache/${TAGCACHE_FILE} -l ./.tagcache --get
echo -en 'travis_fold:end:retrieve-tag-cache\\r'
make push-manifest
if [ -z "$BUILD_MANIFEST" ] || [ "$BUILD_MANIFEST" = false ]; then
./travis-build-scripts/cleanup-cache.sh
fi
exit 0
fi
if [ "$BUILD_MANIFEST" = true ] ; then
echo 'Retrieving remote tagcache for building manifest file' && echo -en 'travis_fold:start:retrieve-tag-cache\\r'
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} -f cache/${TAGCACHE_FILE} -l ./.tagcache --get
echo 'Preparing build manifest'
make build-manifest
make commit-build-manifest
./travis-build-scripts/cleanup-cache.sh
exit 0
fi
echo 'Downgrading Docker (if necessary)...' && echo -en 'travis_fold:start:docker-downgrade\\r'
eval "$DOCKER_DOWNGRADE"
echo -en 'travis_fold:end:docker-downgrade\\r'
## Build images
./travis-build-scripts/build.sh
## Test images
./travis-build-scripts/test.sh
## Push images
if [ -z "$BUILD_INTERNAL_LEVEL" ] ; then
if [ "$BUILD_ALL" = true ] ; then
./travis-build-scripts/push.sh developer
./travis-build-scripts/push.sh production
fi
else
if [[ "$BUILD_INTERNAL_LEVEL" == *".DE"* ]]; then
./travis-build-scripts/push.sh developer
else
./travis-build-scripts/push.sh production
fi
fi
if [ "$LTS" = true ] ; then
printf '\nIn CD stream but building LTS image. Do not push LTS image to artifactory\n'
fi

54
travis-build-scripts/test.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
# © Copyright IBM Corporation 2019, 2020
#
# 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
#Adding SKIP_UNIT_TEST parameter which can be set in the environment to skip running the unit tests
if [ ! "$SKIP_UNIT_TEST" ] ; then
if [ -z "$BUILD_INTERNAL_LEVEL" ] ; then
if [ "$LTS" != true ] ; then
echo 'Testing Developer image...' && echo -en 'travis_fold:start:test-devserver\\r'
make test-devserver
echo -en 'travis_fold:end:test-devserver\\r'
fi
if [ "$BUILD_ALL" = true ] || [ "$LTS" = true ] ; then
if [[ "$ARCH" = "amd64" || "$ARCH" = "s390x" || "$ARCH" = "ppc64le" ]] ; then
echo 'Testing Production image...' && echo -en 'travis_fold:start:test-advancedserver\\r'
make test-advancedserver
echo -en 'travis_fold:end:test-advancedserver\\r'
fi
fi
else
if [[ "$BUILD_INTERNAL_LEVEL" == *".DE"* ]]; then
echo 'Testing Developer image...' && echo -en 'travis_fold:start:test-devserver\\r'
make test-devserver
echo -en 'travis_fold:end:test-devserver\\r'
else
echo 'Testing Production image...' && echo -en 'travis_fold:start:test-advancedserver\\r'
make test-advancedserver
echo -en 'travis_fold:end:test-advancedserver\\r'
fi
fi
else
echo "Skipping unit tests as SKIP_UNIT_TEST is set"
fi
echo 'Running gosec scan...' && echo -en 'travis_fold:start:gosec-scan\\r'
if [ "$ARCH" = "amd64" ] ; then
make gosec
else
echo "Gosec not available on ppc64le/s390x...skipping gosec scan"
fi
echo -en 'travis_fold:end:gosec-scan\\r'

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# © Copyright IBM Corporation 2020
#
# 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.
k=0
dd=$(date)
# Output 200 lines of dummy output to force the logs to flush if they have broken, happens every 8 mins
while true; do
echo -e "travis_fold:start:build_heartbeat.$k\033[33;1mDumping heartbeat logs to keep build alive - $dd\033[0m"
for i in {1..200}; do
echo "Keepalive $i"
done
echo -e "\ntravis_fold:end:build_heartbeat.$k\r"
sleep 120
k=$((k+1))
dd=$(date)
done

View File

@@ -0,0 +1,41 @@
#!/bin/bash
# © Copyright IBM Corporation 2024
#
# 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.
GREEN="\033[32m"
RED="\033[31m"
END="\033[0m"
RIGHTARROW="\xE2\x96\xB6"
GREENRIGHTARROW=${GREEN}${RIGHTARROW}${END}
TICK="\xE2\x9C\x94"
CROSS="\xE2\x9C\x97"
GREENTICK=${GREEN}${TICK}${END}
REDCROSS=${RED}${CROSS}${END}
printf "${GREENRIGHTARROW} Attempting to trigger new release-checks build\n"
repo_name=$(echo "${TRAVIS_REPO_SLUG}" | cut -d'/' -f2-)
request_body="{ \"request\": { \"message\": \"Trigger release checks build from ${repo_name}:${TRAVIS_BRANCH}\", \"branch\": \"main\", \"merge_mode\": \"deep_merge_append\", \"config\": { \"env\": { \"global\": [ \"EVENT_SOURCE=${repo_name}\" ]}}}}"
request_response="$(curl -X POST -H "Content-Type: application/json" -H "Travis-API-Version: 3" -H "Authorization: token ${TRAVIS_TOKEN}" -d "${request_body}" https://v3.travis.ibm.com/api/repo/mq-cloudpak%2Frelease-checks/requests -o /dev/null -w "%{http_code}" -s)"
if [ "$request_response" != "202" ]; then
printf "${REDCROSS} ${RED}Could not create new request${END}\n"
exit 1
else
printf "${GREENTICK} Successfully created new request\n"
fi