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

27
Jenkinsfile vendored
View File

@ -44,7 +44,7 @@ stage('Configure') {
// buildEnv('8', 'sybase'),
buildEnv('8', 'hana', 'HANA'),
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
// buildEnv('8', 'edb')
];
@ -72,9 +72,10 @@ stage('Build') {
environments.each { BuildEnvironment buildEnv ->
executions.put(buildEnv.tag, {
runBuildOnNode(buildEnv.node) {
// Use withEnv instead of setting env directly, as that is global!
// See https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md
withEnv(["JAVA_HOME=${tool buildEnv.buildJdkTool}", "PATH+JAVA=${tool buildEnv.buildJdkTool}/bin"]) {
def containerName = null
env.JAVA_HOME="${tool buildEnv.buildJdkTool}"
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}"
stage('Checkout') {
checkout scm
}
@ -191,6 +192,13 @@ stage('Build') {
if ( containerName != null ) {
sh "docker rm -f ${containerName}"
}
if ( buildEnv.notificationRecipients != null ) {
notifyBuildResult(
maintainers: buildEnv.notificationRecipients,
notifySuccessAfterSuccess: false
)
}
}
}
}
})
@ -203,11 +211,15 @@ stage('Build') {
// Job-specific helpers
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) {
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 {
@ -216,11 +228,13 @@ public class BuildEnvironment {
private String testJdkTool;
private String dbName;
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.dbName = dbName;
this.node = node;
this.notificationRecipients = notificationRecipients;
String buildJdkTool;
String testJdkTool;
switch ( version ) {
@ -239,6 +253,7 @@ public class BuildEnvironment {
String toString() { getTag() }
String getTag() { "jdk-$version-$dbName" }
String getNode() { node }
String getNotificationRecipients() { notificationRecipients }
}
void runBuildOnNode(String label, Closure body) {