forked from pgspider/influxdb_fdw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
78 lines (76 loc) · 2.72 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def NODE_NAME = 'AWS_Instance_CentOS'
def BRANCH_NAME = 'Branch [' + env.BRANCH_NAME + ']'
def BUILD_INFO = 'Jenkins job: ' + env.BUILD_URL
def MAIL_TO='$DEFAULT_RECIPIENTS'
def MAIL_SUBJECT='[CI PGSpider] InfluxDB FDW Test FAILED ' + BRANCH_NAME
def INFLUXDB_FDW_URL = 'https://github.com/pgspider/influxdb_fdw.git'
def retrySh(String shCmd) {
def MAX_RETRY = 10
script {
int status = 1;
for (int i = 0; i < MAX_RETRY; i++) {
status = sh(returnStatus: true, script: shCmd)
if (status == 0) {
echo "SUCCESS: "+shCmd
break
} else {
echo "RETRY: "+shCmd
sleep 5
}
}
if (status != 0) {
sh(shCmd)
}
}
}
pipeline {
agent {
node {
label NODE_NAME
}
}
triggers {
pollSCM('H/30 * * * *')
}
stages {
stage('Build') {
steps {
sh '''
rm -rf postgresql || true
tar -zxvf /home/jenkins/Postgres/postgresql.tar.gz > /dev/null
'''
dir("postgresql/contrib") {
sh 'rm -rf influxdb_fdw || true'
retrySh('git clone ' + INFLUXDB_FDW_URL)
}
}
post {
failure {
echo '** BUILD FAILED !!! NEXT STAGE WILL BE SKIPPED **'
emailext subject: "${MAIL_SUBJECT}", body: BUILD_INFO + "\nGit commit: " + env.GIT_URL.replace(".git", "/commit/") + env.GIT_COMMIT + "\n" + '${BUILD_LOG, maxLines=200, escapeHtml=false}', to: "${MAIL_TO}", attachLog: false
}
}
}
stage('influxdb_fdw_test') {
steps {
dir("postgresql/contrib/influxdb_fdw") {
catchError() {
sh '''
chmod +x ./*.sh || true
rm -rf make_check.out || true
./test_extra.sh
'''
}
script {
status = sh(returnStatus: true, script: "grep -q 'All [0-9]* tests passed' 'make_check.out'")
if (status != 0) {
unstable(message: "Set UNSTABLE result")
emailext subject: "${MAIL_SUBJECT}", body: BUILD_INFO + "\nGit commit: " + env.GIT_URL.replace(".git", "/commit/") + env.GIT_COMMIT + "\n" + '${FILE,path="make_check.out"}', to: "${MAIL_TO}", attachLog: false
sh 'cat regression.diffs || true'
}
}
}
}
}
}
}