HHH-14512 Add Jenkinsfile for matrix build
This commit is contained in:
parent
8dd0ed7c2d
commit
34f0b08c24
|
@ -33,7 +33,7 @@ jobs:
|
|||
experimental: false
|
||||
- rdbms: derby
|
||||
experimental: false
|
||||
- rdbms: mysql
|
||||
- rdbms: mysql8
|
||||
experimental: false
|
||||
- rdbms: mariadb
|
||||
experimental: false
|
||||
|
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
import groovy.transform.Field
|
||||
|
||||
/*
|
||||
* See https://github.com/hibernate/hibernate-jenkins-pipeline-helpers
|
||||
*/
|
||||
@Library('hibernate-jenkins-pipeline-helpers@1.5') _
|
||||
import org.hibernate.jenkins.pipeline.helpers.job.JobHelper
|
||||
|
||||
@Field final String NODE_PATTERN_BASE = 'Worker&&Containers'
|
||||
@Field List<BuildEnvironment> environments
|
||||
|
||||
this.helper = new JobHelper(this)
|
||||
|
||||
helper.runWithNotification {
|
||||
|
||||
stage('Configure') {
|
||||
this.environments = [
|
||||
buildEnv('8', 'h2'),
|
||||
buildEnv('8', 'hsqldb'),
|
||||
buildEnv('8', 'derby'),
|
||||
buildEnv('8', 'mysql8'),
|
||||
buildEnv('8', 'mariadb'),
|
||||
buildEnv('8', 'postgresql'),
|
||||
buildEnv('8', 'oracle'),
|
||||
buildEnv('8', 'oracle_ee'),
|
||||
buildEnv('8', 'db2'),
|
||||
buildEnv('8', 'mssql'),
|
||||
buildEnv('8', 'sybase'),
|
||||
buildEnv('8', 'hana', 'HANA'),
|
||||
buildEnv('8', 'edb')
|
||||
];
|
||||
|
||||
helper.configure {
|
||||
file 'job-configuration.yaml'
|
||||
// We don't require the following, but the build helper plugin apparently does
|
||||
jdk {
|
||||
defaultTool 'OpenJDK 8 Latest'
|
||||
}
|
||||
maven {
|
||||
defaultTool 'Apache Maven 3.8'
|
||||
}
|
||||
}
|
||||
properties([
|
||||
buildDiscarder(
|
||||
logRotator(daysToKeepStr: '90')
|
||||
),
|
||||
helper.generateNotificationProperty()
|
||||
])
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
Map<String, Closure> executions = [:]
|
||||
environments.each { BuildEnvironment buildEnv ->
|
||||
executions.put(buildEnv.tag, {
|
||||
runBuildOnNode(buildEnv.node) {
|
||||
env.JAVA_HOME="${tool buildEnv.buildJdkTool}"
|
||||
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}"
|
||||
stage('Checkout') {
|
||||
checkout scm
|
||||
}
|
||||
stage('Start database') {
|
||||
switch (buildEnv.dbName) {
|
||||
case "mysql8":
|
||||
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
|
||||
docker.image('mysql:8.0.21').pull()
|
||||
}
|
||||
sh "./docker_db.sh mysql_8_0"
|
||||
break;
|
||||
case "mariadb":
|
||||
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
|
||||
docker.image('mariadb:10.5.8').pull()
|
||||
}
|
||||
sh "./docker_db.sh mariadb"
|
||||
break;
|
||||
case "postgresql":
|
||||
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
|
||||
docker.image('postgres:9.5').pull()
|
||||
}
|
||||
sh "./docker_db.sh postgresql_9_5"
|
||||
break;
|
||||
case "oracle":
|
||||
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
|
||||
docker.image('quillbuilduser/oracle-18-xe').pull()
|
||||
}
|
||||
sh "./docker_db.sh oracle"
|
||||
break;
|
||||
case "db2":
|
||||
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
|
||||
docker.image('ibmcom/db2:11.5.5.0').pull()
|
||||
}
|
||||
sh "./docker_db.sh db2"
|
||||
break;
|
||||
case "mssql":
|
||||
docker.image('mcr.microsoft.com/mssql/server:2017-CU13').pull()
|
||||
sh "./docker_db.sh mssql"
|
||||
break;
|
||||
case "sybase":
|
||||
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
|
||||
docker.image('nguoianphu/docker-sybase').pull()
|
||||
}
|
||||
sh "./docker_db.sh sybase"
|
||||
break;
|
||||
case "edb":
|
||||
docker.withRegistry('https://containers.enterprisedb.com', 'hibernateci.containers.enterprisedb.com') {
|
||||
// withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'hibernateci.containers.enterprisedb.com',
|
||||
// usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
|
||||
// sh 'docker login -u "$USERNAME" -p "$PASSWORD" https://containers.enterprisedb.com'
|
||||
docker.image('containers.enterprisedb.com/edb/edb-as-lite:v11').pull()
|
||||
}
|
||||
sh "./docker_db.sh edb"
|
||||
break;
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
String goal;
|
||||
String lockableResource;
|
||||
switch (buildEnv.dbName) {
|
||||
case "h2":
|
||||
case "derby":
|
||||
case "hsqldb":
|
||||
goal = "-Pdb=${buildEnv.dbName}"
|
||||
break;
|
||||
case "mysql8":
|
||||
goal = "-Pdb=mysql_ci"
|
||||
break;
|
||||
case "postgresql":
|
||||
goal = "-Pdb=pgsql_ci"
|
||||
break;
|
||||
case "oracle":
|
||||
goal = "-Pdb=oracle_ci -PexcludeTests=**.LockTest.testQueryTimeout*"
|
||||
break;
|
||||
case "oracle_ee":
|
||||
goal = "-Pdb=oracle_jenkins"
|
||||
lockableResource = 'ORACLE_RDS'
|
||||
break;
|
||||
case "hana":
|
||||
goal = "-Pdb=hana_jenkins"
|
||||
break;
|
||||
default:
|
||||
goal = "-Pdb=${buildEnv.dbName}_ci"
|
||||
break;
|
||||
}
|
||||
String cmd = "./gradlew check ${goal} -Plog-test-progress=true --stacktrace";
|
||||
try {
|
||||
if (lockableResource == null) {
|
||||
sh cmd
|
||||
}
|
||||
else {
|
||||
lock(lockableResource) {
|
||||
sh cmd
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
junit '**/target/test-results/test/*.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
parallel(executions)
|
||||
}
|
||||
|
||||
} // End of helper.runWithNotification
|
||||
|
||||
// Job-specific helpers
|
||||
|
||||
BuildEnvironment buildEnv(String version, String dbName) {
|
||||
return new BuildEnvironment( version, dbName, NODE_PATTERN_BASE );
|
||||
}
|
||||
|
||||
BuildEnvironment buildEnv(String version, String dbName, String node) {
|
||||
return new BuildEnvironment( version, dbName, node );
|
||||
}
|
||||
|
||||
public class BuildEnvironment {
|
||||
private String version;
|
||||
private String buildJdkTool;
|
||||
private String testJdkTool;
|
||||
private String dbName;
|
||||
private String node;
|
||||
|
||||
public BuildEnvironment(String version, String dbName, String node) {
|
||||
this.version = version;
|
||||
this.dbName = dbName;
|
||||
this.node = node;
|
||||
String buildJdkTool;
|
||||
String testJdkTool;
|
||||
switch ( version ) {
|
||||
case "8":
|
||||
buildJdkTool = testJdkTool = "OpenJDK 8 Latest";
|
||||
break;
|
||||
case "11":
|
||||
buildJdkTool = testJdkTool = "OpenJDK 11 Latest";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unsupported version: ${version}" );
|
||||
}
|
||||
this.buildJdkTool = buildJdkTool;
|
||||
this.testJdkTool = testJdkTool;
|
||||
}
|
||||
String toString() { getTag() }
|
||||
String getTag() { "jdk-$version-$dbName" }
|
||||
String getNode() { node }
|
||||
}
|
||||
|
||||
void runBuildOnNode(String label, Closure body) {
|
||||
node( label ) {
|
||||
pruneDockerContainers()
|
||||
try {
|
||||
timeout( [time: 1, unit: 'HOURS'], body )
|
||||
}
|
||||
finally {
|
||||
pruneDockerContainers()
|
||||
}
|
||||
}
|
||||
}
|
||||
void pruneDockerContainers() {
|
||||
if ( !sh( script: 'which docker', returnStdout: true ).trim().isEmpty() ) {
|
||||
sh 'docker container prune -f || true'
|
||||
sh 'docker image prune -f || true'
|
||||
sh 'docker network prune -f || true'
|
||||
sh 'docker volume prune -f || true'
|
||||
}
|
||||
}
|
|
@ -325,7 +325,7 @@ EOF"
|
|||
|
||||
hana() {
|
||||
temp_dir=$(mktemp -d)
|
||||
echo '{"main_password" : "H1bernate_test"}' >$temp_dir/password.json
|
||||
echo '{"master_password" : "H1bernate_test"}' >$temp_dir/password.json
|
||||
chmod 777 -R $temp_dir
|
||||
docker rm -f hana || true
|
||||
docker run -d --name hana -p 39013:39013 -p 39017:39017 -p 39041-39045:39041-39045 -p 1128-1129:1128-1129 -p 59013-59014:59013-59014 \
|
||||
|
|
|
@ -85,14 +85,14 @@ ext {
|
|||
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
|
||||
'jdbc.user' : 'hibernate_orm_test',
|
||||
'jdbc.pass' : 'hibernate_orm_test',
|
||||
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?useSSL=false'
|
||||
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?allowPublicKeyRetrieval=true'
|
||||
],
|
||||
mysql_ci : [
|
||||
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
|
||||
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
|
||||
'jdbc.user' : 'hibernate_orm_test',
|
||||
'jdbc.pass' : 'hibernate_orm_test',
|
||||
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?useSSL=false'
|
||||
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?allowPublicKeyRetrieval=true'
|
||||
],
|
||||
// uses docker mysql_8_0
|
||||
mysql8_spatial_ci: [
|
||||
|
@ -100,7 +100,7 @@ ext {
|
|||
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
|
||||
'jdbc.user' : 'hibernate_orm_test',
|
||||
'jdbc.pass' : 'hibernate_orm_test',
|
||||
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?useSSL=false'
|
||||
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?allowPublicKeyRetrieval=true'
|
||||
],
|
||||
mariadb : [
|
||||
'db.dialect' : 'org.hibernate.dialect.MariaDBDialect',
|
||||
|
@ -138,6 +138,13 @@ ext {
|
|||
'jdbc.pass' : 'hibernate_orm_test',
|
||||
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/xe'
|
||||
],
|
||||
oracle_jenkins : [
|
||||
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
|
||||
'jdbc.driver': 'oracle.jdbc.OracleDriver',
|
||||
'jdbc.user' : 'hibernate_orm_test',
|
||||
'jdbc.pass' : 'hibernate_orm_test',
|
||||
'jdbc.url' : 'jdbc:oracle:thin:@hibernate-testing-oracle-se.ccuzkqo3zqzq.us-east-1.rds.amazonaws.com:1521:ORCL'
|
||||
],
|
||||
// Use ./docker_db.sh oracle_ee to start the database
|
||||
oracle_docker : [
|
||||
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
|
||||
|
@ -225,11 +232,11 @@ ext {
|
|||
// Disable prepared statement caching due to https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.04/en-US/78f2163887814223858e4369d18e2847.html
|
||||
'jdbc.url' : 'jdbc:sap://' + dbHost + ':443/?encrypt=true&validateCertificate=false&statementCacheSize=0'
|
||||
],
|
||||
hana_vlad : [
|
||||
hana_jenkins : [
|
||||
'db.dialect' : 'org.hibernate.dialect.HANAColumnStoreDialect',
|
||||
'jdbc.driver': 'com.sap.db.jdbc.Driver',
|
||||
'jdbc.user' : 'VLAD',
|
||||
'jdbc.pass' : 'V1ad_test',
|
||||
'jdbc.user' : 'HIBERNATE_TEST',
|
||||
'jdbc.pass' : 'H1bernate_test',
|
||||
// Disable prepared statement caching due to https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.04/en-US/78f2163887814223858e4369d18e2847.html
|
||||
'jdbc.url' : 'jdbc:sap://' + dbHost + ':39015/?statementCacheSize=0'
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue