-
Notifications
You must be signed in to change notification settings - Fork 100
/
ghpr_check2.groovy
139 lines (135 loc) · 5.71 KB
/
ghpr_check2.groovy
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// REF: https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-pipeline
// Keep small than 400 lines: https://issues.jenkins.io/browse/JENKINS-37984
// should triggerd for master and latest release branches
@Library('tipipeline') _
final K8S_NAMESPACE = "jenkins-tidb"
final GIT_FULL_REPO_NAME = 'pingcap/tidb'
final POD_TEMPLATE_FILE = 'pipelines/pingcap/tidb/latest/pod-ghpr_check2.yaml'
final REFS = readJSON(text: params.JOB_SPEC).refs
pipeline {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
defaultContainer 'golang'
}
}
options {
timeout(time: 30, unit: 'MINUTES')
parallelsAlwaysFailFast()
}
environment {
FILE_SERVER_URL = 'http://fileserver.pingcap.net'
}
stages {
stage('Debug info') {
steps {
sh label: 'Debug info', script: """
printenv
echo "-------------------------"
go env
echo "-------------------------"
echo "debug command: kubectl -n ${K8S_NAMESPACE} exec -ti ${NODE_NAME} bash"
"""
container(name: 'net-tool') {
sh 'dig github.com'
}
}
}
stage('Checkout') {
// FIXME(wuhuizuo): catch AbortException and set the job abort status
// REF: https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L1161
steps {
dir('tidb') {
cache(path: "./", filter: '**/*', key: "git/pingcap/tidb/rev-${REFS.pulls[0].sha}", restoreKeys: ['git/pingcap/tidb/rev-']) {
retry(2) {
script {
prow.checkoutRefs(REFS)
}
}
}
}
}
}
stage("Prepare") {
steps {
dir('tidb') {
cache(path: "./bin", filter: '**/*', key: "binary/pingcap/tidb/tidb-server/rev-${REFS.base_sha}-${REFS.pulls[0].sha}") {
sh label: 'tidb-server', script: 'ls bin/tidb-server || go build -o bin/tidb-server github.com/pingcap/tidb/tidb-server'
}
script {
component.fetchAndExtractArtifact(FILE_SERVER_URL, 'tikv', REFS.base_ref, REFS.pulls[0].title, 'centos7/tikv-server.tar.gz', 'bin')
component.fetchAndExtractArtifact(FILE_SERVER_URL, 'pd', REFS.base_ref, REFS.pulls[0].title, 'centos7/pd-server.tar.gz', 'bin')
}
// cache it for other pods
cache(path: "./", filter: '**/*', key: "ws/${BUILD_TAG}") {
sh """
mv bin/tidb-server bin/explain_test_tidb-server
touch rev-${REFS.pulls[0].sha}
"""
}
}
}
}
stage('Checks') {
matrix {
axes {
axis {
name 'SCRIPT_AND_ARGS'
values(
'explaintest.sh y',
'explaintest.sh n',
'run_real_tikv_tests.sh bazel_brietest',
'run_real_tikv_tests.sh bazel_pessimistictest',
'run_real_tikv_tests.sh bazel_sessiontest',
'run_real_tikv_tests.sh bazel_statisticstest',
'run_real_tikv_tests.sh bazel_txntest',
'run_real_tikv_tests.sh bazel_addindextest',
)
}
}
agent{
kubernetes {
namespace K8S_NAMESPACE
defaultContainer 'golang'
yamlFile POD_TEMPLATE_FILE
}
}
stages {
stage('Test') {
options { timeout(time: 30, unit: 'MINUTES') }
steps {
dir('tidb') {
cache(path: "./", filter: '**/*', key: "ws/${BUILD_TAG}") {
sh "ls -l rev-${REFS.pulls[0].sha}" // will fail when not found in cache or no cached.
}
sh 'chmod +x ../scripts/pingcap/tidb/*.sh'
sh "${WORKSPACE}/scripts/pingcap/tidb/${SCRIPT_AND_ARGS}"
}
}
post {
failure {
dir("checks-collation-enabled") {
archiveArtifacts(artifacts: 'pd*.log, tikv*.log, explain-test.out', allowEmptyArchive: true)
}
}
}
}
}
}
}
}
post {
success {
// Upload check flag to fileserver
sh "echo done > done && curl -F ci_check/${JOB_NAME}/${REFS.pulls[0].sha}=@done ${FILE_SERVER_URL}/upload"
}
// TODO(wuhuizuo): put into container lifecyle preStop hook.
always {
container('report') {
sh "bash scripts/plugins/report_job_result.sh ${currentBuild.result} result.json || true"
}
archiveArtifacts(artifacts: 'result.json', fingerprint: true, allowEmptyArchive: true)
}
}
}