Setup notifications for PingCAP on TiDB environment

This commit is contained in:
Christian Beikov 2021-10-20 12:15:44 +02:00
parent ae8bedfa6d
commit c63308e501
1 changed files with 135 additions and 120 deletions

255
Jenkinsfile vendored
View File

@ -44,7 +44,7 @@ stage('Configure') {
// buildEnv('8', 'sybase'), // buildEnv('8', 'sybase'),
buildEnv('8', 'hana', 'HANA'), buildEnv('8', 'hana', 'HANA'),
buildEnv('8', 's390x', 's390x'), buildEnv('8', 's390x', 's390x'),
buildEnv('8', 'tidb', 'tidb'), buildEnv('8', 'tidb', 'tidb', 'tidb_hibernate@pingcap.com'),
// Disable EDB for now as the image is not available anymore // Disable EDB for now as the image is not available anymore
// buildEnv('8', 'edb') // buildEnv('8', 'edb')
]; ];
@ -72,124 +72,132 @@ stage('Build') {
environments.each { BuildEnvironment buildEnv -> environments.each { BuildEnvironment buildEnv ->
executions.put(buildEnv.tag, { executions.put(buildEnv.tag, {
runBuildOnNode(buildEnv.node) { runBuildOnNode(buildEnv.node) {
def containerName = null // Use withEnv instead of setting env directly, as that is global!
env.JAVA_HOME="${tool buildEnv.buildJdkTool}" // See https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}" withEnv(["JAVA_HOME=${tool buildEnv.buildJdkTool}", "PATH+JAVA=${tool buildEnv.buildJdkTool}/bin"]) {
stage('Checkout') { def containerName = null
checkout scm stage('Checkout') {
} checkout scm
try { }
stage('Start database') { try {
switch (buildEnv.dbName) { stage('Start database') {
case "mysql8": switch (buildEnv.dbName) {
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') { case "mysql8":
docker.image('mysql:8.0.21').pull() 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" }
containerName = "mysql" sh "./docker_db.sh mysql_8_0"
break; containerName = "mysql"
case "mariadb": break;
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') { case "mariadb":
docker.image('mariadb:10.5.8').pull() docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
} docker.image('mariadb:10.5.8').pull()
sh "./docker_db.sh mariadb" }
containerName = "mariadb" sh "./docker_db.sh mariadb"
break; containerName = "mariadb"
case "postgresql_9_5": break;
// use the postgis image to enable the PGSQL GIS (spatial) extension case "postgresql_9_5":
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') { // use the postgis image to enable the PGSQL GIS (spatial) extension
docker.image('postgis/postgis:9.5-2.5').pull() docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
} docker.image('postgis/postgis:9.5-2.5').pull()
sh "./docker_db.sh postgresql_9_5" }
containerName = "postgres" sh "./docker_db.sh postgresql_9_5"
break; containerName = "postgres"
case "postgresql_13": break;
// use the postgis image to enable the PGSQL GIS (spatial) extension case "postgresql_13":
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') { // use the postgis image to enable the PGSQL GIS (spatial) extension
docker.image('postgis/postgis:13-3.1').pull() docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
} docker.image('postgis/postgis:13-3.1').pull()
sh "./docker_db.sh postgresql_13" }
containerName = "postgres" sh "./docker_db.sh postgresql_13"
break; containerName = "postgres"
case "oracle": break;
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') { case "oracle":
docker.image('quillbuilduser/oracle-18-xe').pull() docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
} docker.image('quillbuilduser/oracle-18-xe').pull()
sh "./docker_db.sh oracle" }
containerName = "oracle" sh "./docker_db.sh oracle"
break; containerName = "oracle"
case "db2": break;
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') { case "db2":
docker.image('ibmcom/db2:11.5.5.0').pull() 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" }
containerName = "db2" sh "./docker_db.sh db2"
break; containerName = "db2"
case "mssql": break;
docker.image('mcr.microsoft.com/mssql/server:2017-CU13').pull() case "mssql":
sh "./docker_db.sh mssql" docker.image('mcr.microsoft.com/mssql/server:2017-CU13').pull()
containerName = "mssql" sh "./docker_db.sh mssql"
break; containerName = "mssql"
case "sybase": break;
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') { case "sybase":
docker.image('nguoianphu/docker-sybase').pull() docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
} docker.image('nguoianphu/docker-sybase').pull()
sh "./docker_db.sh sybase" }
containerName = "sybase" sh "./docker_db.sh sybase"
break; containerName = "sybase"
case "edb": break;
docker.withRegistry('https://containers.enterprisedb.com', 'hibernateci.containers.enterprisedb.com') { case "edb":
// withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'hibernateci.containers.enterprisedb.com', docker.withRegistry('https://containers.enterprisedb.com', 'hibernateci.containers.enterprisedb.com') {
// usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { // withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'hibernateci.containers.enterprisedb.com',
// sh 'docker login -u "$USERNAME" -p "$PASSWORD" https://containers.enterprisedb.com' // usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
docker.image('containers.enterprisedb.com/edb/edb-as-lite:v11').pull() // 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" }
containerName = "edb" sh "./docker_db.sh edb"
break; containerName = "edb"
break;
}
}
stage('Test') {
switch (buildEnv.dbName) {
case "h2":
case "derby":
case "hsqldb":
runTest("-Pdb=${buildEnv.dbName}")
break;
case "mysql8":
runTest("-Pdb=mysql_ci")
break;
case "tidb":
runTest("-Pdb=tidb -DdbHost=localhost:4000", 'TIDB')
break;
case "postgresql_9_5":
case "postgresql_13":
runTest("-Pdb=pgsql_ci")
break;
case "oracle":
runTest("-Pdb=oracle_ci -PexcludeTests=**.LockTest.testQueryTimeout*")
break;
case "oracle_ee":
runTest("-Pdb=oracle_jenkins", 'ORACLE_RDS')
break;
case "hana":
runTest("-Pdb=hana_jenkins", 'HANA')
break;
case "edb":
runTest("-Pdb=edb_ci -DdbHost=localhost:5433")
break;
case "s390x":
runTest("-Pdb=h2")
break;
default:
runTest("-Pdb=${buildEnv.dbName}_ci")
break;
}
} }
} }
stage('Test') { finally {
switch (buildEnv.dbName) { if ( containerName != null ) {
case "h2": sh "docker rm -f ${containerName}"
case "derby": }
case "hsqldb": if ( buildEnv.notificationRecipients != null ) {
runTest("-Pdb=${buildEnv.dbName}") notifyBuildResult(
break; maintainers: buildEnv.notificationRecipients,
case "mysql8": notifySuccessAfterSuccess: false
runTest("-Pdb=mysql_ci") )
break;
case "tidb":
runTest("-Pdb=tidb -DdbHost=localhost:4000", 'TIDB')
break;
case "postgresql_9_5":
case "postgresql_13":
runTest("-Pdb=pgsql_ci")
break;
case "oracle":
runTest("-Pdb=oracle_ci -PexcludeTests=**.LockTest.testQueryTimeout*")
break;
case "oracle_ee":
runTest("-Pdb=oracle_jenkins", 'ORACLE_RDS')
break;
case "hana":
runTest("-Pdb=hana_jenkins", 'HANA')
break;
case "edb":
runTest("-Pdb=edb_ci -DdbHost=localhost:5433")
break;
case "s390x":
runTest("-Pdb=h2")
break;
default:
runTest("-Pdb=${buildEnv.dbName}_ci")
break;
} }
}
}
finally {
if ( containerName != null ) {
sh "docker rm -f ${containerName}"
} }
} }
} }
@ -203,11 +211,15 @@ stage('Build') {
// Job-specific helpers // Job-specific helpers
BuildEnvironment buildEnv(String version, String dbName) { BuildEnvironment buildEnv(String version, String dbName) {
return new BuildEnvironment( version, dbName, NODE_PATTERN_BASE ); return new BuildEnvironment( version, dbName, NODE_PATTERN_BASE, null );
} }
BuildEnvironment buildEnv(String version, String dbName, String node) { BuildEnvironment buildEnv(String version, String dbName, String node) {
return new BuildEnvironment( version, dbName, node ); return new BuildEnvironment( version, dbName, node, null );
}
BuildEnvironment buildEnv(String version, String dbName, String node, String notificationRecipients) {
return new BuildEnvironment( version, dbName, node, notificationRecipients );
} }
public class BuildEnvironment { public class BuildEnvironment {
@ -216,11 +228,13 @@ public class BuildEnvironment {
private String testJdkTool; private String testJdkTool;
private String dbName; private String dbName;
private String node; private String node;
private String notificationRecipients;
public BuildEnvironment(String version, String dbName, String node) { public BuildEnvironment(String version, String dbName, String node, String notificationRecipients) {
this.version = version; this.version = version;
this.dbName = dbName; this.dbName = dbName;
this.node = node; this.node = node;
this.notificationRecipients = notificationRecipients;
String buildJdkTool; String buildJdkTool;
String testJdkTool; String testJdkTool;
switch ( version ) { switch ( version ) {
@ -239,13 +253,14 @@ public class BuildEnvironment {
String toString() { getTag() } String toString() { getTag() }
String getTag() { "jdk-$version-$dbName" } String getTag() { "jdk-$version-$dbName" }
String getNode() { node } String getNode() { node }
String getNotificationRecipients() { notificationRecipients }
} }
void runBuildOnNode(String label, Closure body) { void runBuildOnNode(String label, Closure body) {
node( label ) { node( label ) {
pruneDockerContainers() pruneDockerContainers()
try { try {
timeout( [time: 120, unit: 'MINUTES'], body ) timeout( [time: 120, unit: 'MINUTES'], body )
} }
finally { finally {
// If this is a PR, we clean the workspace at the end // If this is a PR, we clean the workspace at the end