forked from percona/percona-backup-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
174 lines (162 loc) · 8.06 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
def skipBranchBulds = true
if ( env.CHANGE_URL ) {
skipBranchBulds = false
}
TestsReport = '| Test name | Status |\\r\\n| ------------- | ------------- |'
testsReportMap = [:]
void makeReport() {
for ( test in testsReportMap ) {
TestsReport = TestsReport + "\\r\\n| ${test.key} | ${test.value} |"
}
}
pipeline {
environment {
AUTHOR_NAME = sh(script: "echo ${CHANGE_AUTHOR_EMAIL} | awk -F'@' '{print \$1}'", , returnStdout: true).trim()
}
agent {
label 'micro-amazon'
}
stages {
stage('Run tests for PBM') {
when {
expression {
!skipBranchBulds
}
}
parallel {
stage('PBM tests mongodb 3.6') {
agent {
label 'docker-32gb'
}
steps {
script {
if ( AUTHOR_NAME == 'null' ) {
AUTHOR_NAME = sh(script: "git show -s --pretty=%ae | awk -F'@' '{print \$1}'", , returnStdout: true).trim()
}
testsReportMap['mongodb 3.6'] = 'failed'
}
withCredentials([file(credentialsId: 'PBM-AWS-S3', variable: 'PBM_AWS_S3_YML'), file(credentialsId: 'PBM-GCS-S3', variable: 'PBM_GCS_S3_YML')]) {
sh '''
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
cp $PBM_AWS_S3_YML ./e2e-tests/docker/conf/aws.yaml
cp $PBM_GCS_S3_YML ./e2e-tests/docker/conf/gcs.yaml
sed -i s:pbme2etest:pbme2etest-36:g ./e2e-tests/docker/conf/aws.yaml
sed -i s:pbme2etest:pbme2etest-36:g ./e2e-tests/docker/conf/gcs.yaml
chmod 664 ./e2e-tests/docker/conf/aws.yaml
chmod 664 ./e2e-tests/docker/conf/gcs.yaml
docker-compose -f ./e2e-tests/docker/docker-compose.yaml build
openssl rand -base64 756 > ./e2e-tests/docker/keyFile
sudo chown 1001:1001 ./e2e-tests/docker/keyFile
sudo chmod 400 ./e2e-tests/docker/keyFile
'''
}
sh '''
export MONGODB_VERSION=3.6
export PBM_TESTS_NO_BUILD=true
./e2e-tests/run-all
'''
script {
testsReportMap['mongodb 3.6'] = 'passed'
}
}
}
stage('PBM tests mongodb 4.0') {
agent {
label 'docker-32gb'
}
steps {
script {
testsReportMap['mongodb 4.0'] = 'failed'
}
withCredentials([file(credentialsId: 'PBM-AWS-S3', variable: 'PBM_AWS_S3_YML'), file(credentialsId: 'PBM-GCS-S3', variable: 'PBM_GCS_S3_YML')]) {
sh '''
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
cp $PBM_AWS_S3_YML ./e2e-tests/docker/conf/aws.yaml
cp $PBM_GCS_S3_YML ./e2e-tests/docker/conf/gcs.yaml
sed -i s:pbme2etest:pbme2etest-40:g ./e2e-tests/docker/conf/aws.yaml
sed -i s:pbme2etest:pbme2etest-40:g ./e2e-tests/docker/conf/gcs.yaml
chmod 664 ./e2e-tests/docker/conf/aws.yaml
chmod 664 ./e2e-tests/docker/conf/gcs.yaml
docker-compose -f ./e2e-tests/docker/docker-compose.yaml build
openssl rand -base64 756 > ./e2e-tests/docker/keyFile
sudo chown 1001:1001 ./e2e-tests/docker/keyFile
sudo chmod 400 ./e2e-tests/docker/keyFile
'''
}
sh '''
export MONGODB_VERSION=4.0
export PBM_TESTS_NO_BUILD=true
./e2e-tests/run-all
'''
script {
testsReportMap['mongodb 4.0'] = 'passed'
}
}
}
stage('PBM tests mongodb 4.2') {
agent {
label 'docker-32gb'
}
steps {
script {
testsReportMap['mongodb 4.2'] = 'failed'
}
withCredentials([file(credentialsId: 'PBM-AWS-S3', variable: 'PBM_AWS_S3_YML'), file(credentialsId: 'PBM-GCS-S3', variable: 'PBM_GCS_S3_YML')]) {
sh '''
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
cp $PBM_AWS_S3_YML ./e2e-tests/docker/conf/aws.yaml
cp $PBM_GCS_S3_YML ./e2e-tests/docker/conf/gcs.yaml
sed -i s:pbme2etest:pbme2etest-42:g ./e2e-tests/docker/conf/aws.yaml
sed -i s:pbme2etest:pbme2etest-42:g ./e2e-tests/docker/conf/gcs.yaml
chmod 664 ./e2e-tests/docker/conf/aws.yaml
chmod 664 ./e2e-tests/docker/conf/gcs.yaml
docker-compose -f ./e2e-tests/docker/docker-compose.yaml build
openssl rand -base64 756 > ./e2e-tests/docker/keyFile
sudo chown 1001:1001 ./e2e-tests/docker/keyFile
sudo chmod 400 ./e2e-tests/docker/keyFile
'''
}
sh '''
export MONGODB_VERSION=4.2
export PBM_TESTS_NO_BUILD=true
./e2e-tests/run-all
'''
script {
testsReportMap['mongodb 4.2'] = 'passed'
}
}
}
}
}
}
post {
always {
script {
if (env.CHANGE_URL) {
withCredentials([string(credentialsId: 'GITHUB_API_TOKEN', variable: 'GITHUB_API_TOKEN')]) {
makeReport()
sh """
curl -v -X POST \
-H "Authorization: token ${GITHUB_API_TOKEN}" \
-d "{\\"body\\":\\"${TestsReport}\\"}" \
"https://api.github.com/repos/\$(echo $CHANGE_URL | cut -d '/' -f 4-5)/issues/${CHANGE_ID}/comments"
"""
}
}
}
sh '''
sudo docker rmi -f \$(sudo docker images -q) || true
sudo rm -rf ./*
'''
deleteDir()
}
failure {
script {
slackSend channel: '#cloud-dev-ci', color: '#FF0000', message: "[${JOB_NAME}]: build ${currentBuild.result}, ${BUILD_URL} owner: @${AUTHOR_NAME}"
}
}
}
}