2020-10-13 01:12:30 +02:00
import groovy.json.*
import java.util.stream.*
if (
2022-10-18 14:53:03 +02:00
! params . DEBEZIUM_REPOSITORY | |
! params . DEBEZIUM_BRANCH | |
! params . DEBEZIUM_ADDITIONAL_REPOSITORIES
2020-10-13 01:12:30 +02:00
) {
error 'Input parameters not provided'
}
GIT_CREDENTIALS_ID = 'debezium-github'
DEBEZIUM_DIR = 'debezium'
2024-06-18 09:37:23 +02:00
HOME_DIR = '/home/cloud-user'
2020-10-13 01:12:30 +02:00
def additionalDirs = [ ]
node ( 'Slave' ) {
2023-01-04 13:38:34 +01:00
catchError {
2020-10-13 01:12:30 +02:00
stage ( 'Initialize' ) {
dir ( '.' ) {
deleteDir ( )
}
checkout ( [ $class : 'GitSCM' ,
2022-10-18 14:53:03 +02:00
branches : [ [ name: "*/$params.DEBEZIUM_BRANCH" ] ] ,
2020-10-13 01:12:30 +02:00
doGenerateSubmoduleConfigurations: false ,
extensions : [ [ $class : 'RelativeTargetDirectory' , relativeTargetDir: DEBEZIUM_DIR ] ] ,
submoduleCfg : [ ] ,
2022-10-18 14:53:03 +02:00
userRemoteConfigs : [ [ url: "https://$params.DEBEZIUM_REPOSITORY" , credentialsId: GIT_CREDENTIALS_ID ] ]
2020-10-13 01:12:30 +02:00
]
)
2022-10-18 14:53:03 +02:00
params . DEBEZIUM_ADDITIONAL_REPOSITORIES . split ( ) . each {
2020-10-13 01:12:30 +02:00
def ( id , repository , branch ) = it . split ( '#' )
checkout ( [ $class : 'GitSCM' ,
branches : [ [ name: "*/$branch" ] ] ,
doGenerateSubmoduleConfigurations: false ,
extensions : [ [ $class : 'RelativeTargetDirectory' , relativeTargetDir: id ] ] ,
submoduleCfg : [ ] ,
userRemoteConfigs : [ [ url: "https://$repository" , credentialsId: GIT_CREDENTIALS_ID ] ]
]
)
additionalDirs < < id
}
2022-06-09 15:43:26 +02:00
dir ( DEBEZIUM_DIR ) {
ORACLE_ARTIFACT_VERSION = ( readFile ( 'pom.xml' ) = ~ /(?ms)<version.oracle.driver>(.+)<\/ version . oracle . driver > / ) [ 0 ] [ 1 ]
ORACLE_ARTIFACT_DIR = "$HOME_DIR/oracle-libs/${ORACLE_ARTIFACT_VERSION}.0"
}
2020-10-13 01:12:30 +02:00
dir ( ORACLE_ARTIFACT_DIR ) {
sh "mvn install:install-file -DgroupId=com.oracle.instantclient -DartifactId=ojdbc8 -Dversion=$ORACLE_ARTIFACT_VERSION -Dpackaging=jar -Dfile=ojdbc8.jar"
sh "mvn install:install-file -DgroupId=com.oracle.instantclient -DartifactId=xstreams -Dversion=$ORACLE_ARTIFACT_VERSION -Dpackaging=jar -Dfile=xstreams.jar"
}
}
stage ( 'Build and deploy Debezium' ) {
dir ( DEBEZIUM_DIR ) {
2022-10-18 14:53:03 +02:00
sh "mvn clean deploy -U -s $env.HOME/.m2/settings-snapshots.xml -DdeployAtEnd=true -DskipITs -DskipTests -Passembly,oracle-all,docs -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.rto=20000 -Dmaven.wagon.http.retryHandler.count=1 -Dmaven.wagon.http.serviceUnavailableRetryStrategy.retryInterval=5000"
2020-10-13 01:12:30 +02:00
}
}
additionalDirs . each { id - >
stage ( "Build and deploy Debezium ${id.capitalize()}" ) {
dir ( id ) {
2023-03-02 08:29:26 +01:00
// Execute a dependency installation script if provided by the repository
sh "if [ -f install-artifacts.sh ]; then ./install-artifacts.sh; fi"
2022-10-18 14:53:03 +02:00
sh "mvn clean deploy -s $env.HOME/.m2/settings-snapshots.xml -DdeployAtEnd=true -DskipITs -DskipTests -Passembly,docs -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.rto=20000 -Dmaven.wagon.http.retryHandler.count=1 -Dmaven.wagon.http.serviceUnavailableRetryStrategy.retryInterval=5000"
2020-10-13 01:12:30 +02:00
}
}
}
}
2023-01-04 13:38:34 +01:00
2023-01-04 13:54:58 +01:00
mail to: params . MAIL_TO , subject: "${env.JOB_NAME} run #${env.BUILD_NUMBER} finished with ${currentBuild.currentResult}" , body: "Run ${env.BUILD_URL} finished with result: ${currentBuild.currentResult}"
2020-10-13 01:12:30 +02:00
}