-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathJenkinsfile
More file actions
239 lines (204 loc) · 7.32 KB
/
Jenkinsfile
File metadata and controls
239 lines (204 loc) · 7.32 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
pipeline {
agent {
docker {
image 'ubuntu'
args '-u root:root'
}
}
stages {
stage('Install General Dependencies') {
steps {
sh '''
# Install packages
apt-get update && \
apt-get -yq install python3-pip python3-psycopg2 python3-mysqldb rsync curl wget lsb-release gnupg2 locales && \
pip3 install configobj 'pylint>=2.17.0,<3.0.0' six 'pymongo>=3.6' && \
python3 --version
locale-gen en_US.UTF-8
'''
}
}
stage('Display OS Info') {
steps {
sh 'cat /etc/os-release'
}
}
stage('Install Holland') {
steps {
sh '''
# Move over to tmp to prevent file permissions issues
mkdir -p /tmp/holland
rsync -art $WORKSPACE/ /tmp/holland/
cd /tmp/holland
# Install Holland
python3 setup.py install
# Install Plugins
for i in `ls -d plugins/holland.*`
do
cd /tmp/holland/${i}
python3 setup.py install
exit_code=$?
if [ $exit_code -ne 0 ]
then
echo "Failed installing $i"
exit $exit_code
fi
done
# Create Holland directories and copy configs
mkdir -p /etc/holland/providers /etc/holland/backupsets /var/log/holland /var/spool/holland
cp ${WORKSPACE}/config/holland.conf /etc/holland/
cp ${WORKSPACE}/config/providers/* /etc/holland/providers/
'''
}
}
stage('Pylint Holland and Plugins') {
parallel {
stage('Pylint Holland') {
steps {
sh 'pylint holland'
}
}
stage('Pylint Plugins') {
steps {
sh '''
pylint_failed=0
for d in $(ls -d ./plugins/*/holland ./contrib/holland-commvault/holland_commvault)
do
echo $d
pylint $d
if [ $? -ne 0 ] && [ $pylint_failed -ne 1 ]
then
pylint_failed=1
fi
done
if [ $pylint_failed -ne 0 ]
then
echo "Pylint failed; please review above output."
exit $pylint_failed
fi
'''
}
}
}
}
stage('Setup MySQL Database') {
steps {
sh '''
export DEBIAN_FRONTEND=noninteractive
# Try to prevent mysql from starting automatically
echo 'exit 101' > /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d
# Using community repo to simplify installation of mysql-shell
wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb
echo "mysql-apt-config mysql-apt-config/select-server select mysql-8.0" | debconf-set-selections
echo "mysql-apt-config mysql-apt-config/select-tools select Enabled" | debconf-set-selections
dpkg -i mysql-apt-config_0.8.29-1_all.deb
# Install mysql-server and mysql-shell
apt-get update && \
apt-get -yq install mysql-server mysql-shell
# Initialize MySQL
rm -rf /var/lib/mysql/* && \
mysqld --initialize-insecure --user=mysql > /dev/null 2>&1
# Start MySQL
mysqld_safe --user=mysql > /dev/null 2>&1 &
sleep 10
# Download and extract Sakila database
wget -q https://downloads.mysql.com/docs/sakila-db.tar.gz -O /tmp/sakila-db.tar.gz && \
tar -xzf /tmp/sakila-db.tar.gz -C /tmp && \
rm /tmp/sakila-db.tar.gz
# Populate MySQL with Sakila database
mysql -e "SOURCE /tmp/sakila-db/sakila-schema.sql;" && \
mysql -e "SOURCE /tmp/sakila-db/sakila-data.sql;"
'''
}
}
stage('Test Holland Command Plugin') {
steps {
sh '''
# Test holland bk dump-instance --dry-run
holland mc --name command command
# Set command setting in backupset config
sed -i 's|# command = "" # no default|command = rsync -av /var/lib/mysql {backup_data_dir}|' /etc/holland/backupsets/command.conf
# Test holland bk command --dry-run
holland bk command --dry-run
# Test holland bk command
holland bk command
'''
}
}
stage('Test Holland with MySQL') {
steps {
sh '''
# Test holland mc -f
holland mc -f /tmp/mysqldump.conf mysqldump
# Create a mysqldump backupset
holland mc --name mysqldump mysqldump
# Test holland bk mysqldump --dry-run
holland bk mysqldump --dry-run
# Test holland bk mysqldump
holland bk mysqldump
# Test to check for https://github.com/holland-backup/holland/issues/213
sed -i \'s|^estimate-method = plugin$|estimate-method = const:1K|\' /etc/holland/backupsets/mysqldump.conf
holland bk mysqldump
# Test that split command is working as expected
sed -i \'s|^split = no|split = yes|\' /etc/holland/backupsets/mysqldump.conf
holland bk mysqldump
# Create mysqlsh backupsets
holland mc --name mysqlsh-dump-instance mysqlsh-dump-instance
holland mc --name mysqlsh-dump-schemas mysqlsh-dump-schemas
# Specify the schemas to dump for dump-schemas
sed -i 's/schemas = /schemas = mysql,sakila/' /etc/holland/backupsets/mysqlsh-dump-schemas.conf
# Create .my.cnf file for root user. This is needed for mysqlsh to work properly here in
# this pipelline.
printf '[client]\nuser=root\npassword=\nsocket=/var/run/mysqld/mysqld.sock\n' > ~/.my.cnf
chmod 600 ~/.my.cnf
# Test holland bk mysqlsh-dump-instance --dry-run
holland bk mysqlsh-dump-instance --dry-run
# Test holland bk mysqlsh-dump-instance
holland bk mysqlsh-dump-instance
# Test holland bk mysqlsh-dump-schemas --dry-run
holland bk mysqlsh-dump-schemas --dry-run
# Test holland bk mysqlsh-dump-schemas
holland bk mysqlsh-dump-schemas
# Remove .my.cnf file
rm ~/.my.cnf
'''
}
}
stage('Swap to MariaDB 10.11') {
steps {
sh '''
# Stop Running MySQL instance
mysqladmin shutdown
# Remove MySQL packages
rm -rf /etc/mysql /var/lib/mysql /var/log/mysql /var/run/mysqld && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get -yq remove --purge mysql-server mysql-client mysql-common && \
apt-get -yq autoremove && \
apt-get -yq remove dbconfig-mysql
# Install MariaDB 10.11
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- --skip-os-eol-check --mariadb-server-version=mariadb-10.11 && \
apt-get update && \
apt-get -yq install mariadb-server mariadb-client
# Initialize MariaDB
rm -rf /var/lib/mysql && \
mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=normal
# Start MariaDB
mysqld_safe --user=mysql > /dev/null 2>&1 &
sleep 10
'''
}
}
stage('Test Holland with MariaDB') {
steps {
sh '''
# Create a maridb-dump backupset
holland mc --name mariadb-dump mariadb-dump
# Test holland bk maridb-dump --dry-run
holland bk mariadb-dump --dry-run
# Test holland bk maridb-dump
holland bk mariadb-dump
'''
}
}
}
}