DBZ-4601 Upstream AS and KC images jobs have optional Oracle connector

This commit is contained in:
Jiri Novotny 2022-03-01 14:43:44 +01:00 committed by Jakub Cechacek
parent b30a8d8492
commit f16ee5f5ec
6 changed files with 64 additions and 7 deletions

View File

@ -25,6 +25,9 @@ pipelineJob('ocp-upstream-artifact-server-prepare-job') {
textParam('EXTRA_IMAGE_TAGS', 'latest', 'List of extra texts tags for multiple images')
// COMPONENT VERSIONS
stringParam('APICURIO_VERSION', '2.1.0.Final', 'Service registry bits version')
// ORACLE INCLUSION
booleanParam('ORACLE_INCLUDED', false, 'Should Oracle connector be included in image')
stringParam('PRIVATE_QUAY_CREDENTIALS', 'rh-integration-quay-creds', 'Quay.io credentials id to private repo')
}
definition {

View File

@ -28,6 +28,9 @@ pipelineJob('ocp-upstream-kafka-connect-prepare-job') {
// COMPONENT VERSIONS
stringParam('APICURIO_VERSION', '2.1.0.Final', 'Service registry bits version')
stringParam('KAFKA_VERSION', '3.1.0', 'Kafka version')
// ORACLE INCLUSION
booleanParam('ORACLE_INCLUDED', false, 'Should Oracle connector be included in image')
stringParam('PRIVATE_QUAY_CREDENTIALS', 'rh-integration-quay-creds', 'Quay.io credentials id to private repo')
}
definition {

View File

@ -84,6 +84,22 @@ pipeline {
}
}
stage('Login to private Quay repository'){
when(){
expression { params.ORACLE_INCLUDED }
}
steps {
withCredentials([
usernamePassword(credentialsId: "${PRIVATE_QUAY_CREDENTIALS}", usernameVariable: 'PRIVATE_QUAY_USERNAME', passwordVariable: 'PRIVATE_QUAY_PASSWORD'),
]){
sh '''
set -x
docker login -u ${PRIVATE_QUAY_USERNAME} -p ${PRIVATE_QUAY_PASSWORD} quay.io
'''
}
}
}
stage('Build and push image') {
steps {
withCredentials([
@ -99,7 +115,8 @@ pipeline {
--registry="quay.io" --organisation="${QUAY_ORGANISATION}" \\
--dest-login="${QUAY_USERNAME}" \\
--dest-pass="${QUAY_PASSWORD}" \\
--img-output="${WORKSPACE}/published_image_dbz.txt"
--img-output="${WORKSPACE}/published_image_dbz.txt" \\
--oracle-included="${ORACLE_INCLUDED}"
'''
}
}

View File

@ -84,6 +84,22 @@ pipeline {
}
}
stage('Login to private Quay repository'){
when(){
expression { params.ORACLE_INCLUDED }
}
steps {
withCredentials([
usernamePassword(credentialsId: "${PRIVATE_QUAY_CREDENTIALS}", usernameVariable: 'PRIVATE_QUAY_USERNAME', passwordVariable: 'PRIVATE_QUAY_PASSWORD'),
]){
sh '''
set -x
docker login -u ${PRIVATE_QUAY_USERNAME} -p ${PRIVATE_QUAY_PASSWORD} quay.io
'''
}
}
}
stage('Build and push image') {
steps {
withCredentials([
@ -101,7 +117,8 @@ pipeline {
--dest-pass="${QUAY_PASSWORD}" \\
--kc-base-tag="${KC_BASE_TAG}" \\
--kafka-version="${KAFKA_VERSION}" \\
--img-output="${WORKSPACE}/published_image_dbz.txt"
--img-output="${WORKSPACE}/published_image_dbz.txt" \\
--oracle-included="${ORACLE_INCLUDED}"
'''
}
}

View File

@ -5,7 +5,7 @@ DOCKER_FILE=${DIR}/../docker/artifact-server/Dockerfile
PLUGIN_DIR="plugins"
OPTS=$(getopt -o d:f:r:o:t:a: --long dir:,dockerfile:,registry:,organisation:,tags:,auto-tag:,dest-login:,dest-pass:,img-output: -n 'parse-options' -- "$@")
OPTS=$(getopt -o d:f:r:o:t:a: --long dir:,dockerfile:,registry:,organisation:,tags:,auto-tag:,dest-login:,dest-pass:,img-output:,oracle-included: -n 'parse-options' -- "$@")
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
eval set -- "$OPTS"
@ -21,6 +21,7 @@ while true; do
--dest-login ) DEST_LOGIN=$2; shift; shift ;;
--dest-pass ) DEST_PASS=$2; shift; shift ;;
--img-output ) IMAGE_OUTPUT_FILE=$2; shift; shift ;;
--oracle-included ) ORACLE=$2; shift; shift ;;
-h | --help ) PRINT_HELP=true; shift ;;
-- ) shift; break ;;
* ) break ;;
@ -31,7 +32,7 @@ if [ -z "${TAGS}" ] && [ "${AUTO_TAG}" = "false" ]; then
echo "Cannot push image without tag." >&2 ; exit 1 ;
fi
if [ ! -z "${DEST_LOGIN}" ] ; then
if [ ! -z "${DEST_LOGIN}" ] && [ "$ORACLE" = "false" ]; then
docker login -u "${DEST_LOGIN}" -p "${DEST_PASS}" "${REGISTRY}" || { echo "Cannot login to docker image registry" ; exit 1 ; }
fi
@ -46,9 +47,16 @@ cp ~/.m2/repository/io/debezium/debezium-connector-*/"${project_version}"/debezi
cp ~/.m2/repository/io/debezium/debezium-scripting/"${project_version}"/debezium-scripting-*.zip .
mkdir jdbc
cp ~/.m2/repository/com/ibm/db2/jcc/*/jcc-*.jar jdbc/
cp ~/.m2/repository/com/oracle/database/jdbc/ojdbc8/*/ojdbc8-*.jar jdbc/
cp ~/.m2/repository/io/apicurio/apicurio-registry-distro-connect-converter/*/apicurio-registry-*.zip .
if [ "${ORACLE}" = "false" ] ; then
rm debezium-connector-oracle*.zip
else
cp ~/.m2/repository/com/oracle/database/jdbc/ojdbc8/*/ojdbc8-*.jar jdbc/
echo "Changing quay organisation to private rh-integration since ORACLE connector is included"
ORGANISATION="rh_integration"
fi
popd || exit
echo "Copying scripts to" "${BUILD_DIR}"

View File

@ -5,7 +5,7 @@ DOCKER_FILE=${DIR}/../docker/Dockerfile.AMQ
PLUGIN_DIR="plugins"
OPTS=$(getopt -o d:f:r:o:t:a: --long dir:,dockerfile:,registry:,organisation:,tags:,auto-tag:,kc-base-tag:,kafka-version:,dest-login:,dest-pass:,img-output: -n 'parse-options' -- "$@")
OPTS=$(getopt -o d:f:r:o:t:a: --long dir:,dockerfile:,registry:,organisation:,tags:,auto-tag:,kc-base-tag:,kafka-version:,dest-login:,dest-pass:,img-output:,oracle-included: -n 'parse-options' -- "$@")
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
eval set -- "$OPTS"
@ -23,6 +23,7 @@ while true; do
--dest-login ) DEST_LOGIN=$2; shift; shift ;;
--dest-pass ) DEST_PASS=$2; shift; shift ;;
--img-output ) IMAGE_OUTPUT_FILE=$2; shift; shift ;;
--oracle-included ) ORACLE=$2; shift; shift ;;
-h | --help ) PRINT_HELP=true; shift ;;
-- ) shift; break ;;
* ) break ;;
@ -33,7 +34,7 @@ if [ -z "${TAGS}" ] && [ "${AUTO_TAG}" = "false" ]; then
echo "Cannot push image without tag." >&2 ; exit 1 ;
fi
if [ ! -z "${DEST_LOGIN}" ] ; then
if [ ! -z "${DEST_LOGIN}" ] && [ "$ORACLE" = "false" ]; then
docker login -u "${DEST_LOGIN}" -p "${DEST_PASS}" "${REGISTRY}" || { echo "Cannot login to docker image registry" ; exit 1 ; }
fi
@ -56,8 +57,16 @@ unzip -o apicurio-registry-*.zip -d debezium-connector-postgres/
unzip -o apicurio-registry-*.zip -d debezium-connector-mongodb/
unzip -o apicurio-registry-*.zip -d debezium-connector-sqlserver/
unzip -o apicurio-registry-*.zip -d debezium-connector-db2/
unzip -o apicurio-registry-*.zip -d debezium-connector-oracle/
rm apicurio-registry-*.zip
if [ "${ORACLE}" = "false" ] ; then
rm -rf debezium-connector-oracle
else
echo "Changing quay organisation to private rh-integration since ORACLE connector is included"
ORGANISATION="rh_integration"
fi
popd || exit
echo "Copying Dockerfile to" "${BUILD_DIR}"