-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJenkinsfile
More file actions
102 lines (81 loc) · 3.53 KB
/
Jenkinsfile
File metadata and controls
102 lines (81 loc) · 3.53 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
pipeline {
agent {
dockerfile {
// Run as root user inside container
// Mount ~/public_html for copying coverage page over
args '-u root:root -v $HOME/public_html:/html'
}
}
stages {
stage ('Setup Server') {
steps {
// Start MySQL
sh '''
mysqld_safe &
sleep 2
'''
sh '''
/etc/pki/tls/certs/make-dummy-cert /etc/pki/tls/certs/localhost.crt
chmod +r /etc/pki/tls/certs/localhost.crt
# Create a certificate for dynamo user
printf "US\nMass\nBahston\nDynamo\ntest\nlocalhost\n\n" | \
openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout /tmp/x509up_u500 -out /tmp/x509up_u500
chown dynamo:dynamo /tmp/x509up_u500
# Add certificates to trusted
cp /tmp/x509up_u500 /etc/pki/tls/certs/localhost.crt /etc/pki/ca-trust/source/anchors/
update-ca-trust extract
'''
// Lighttpd files
sh '''
sed 's/__ipaddr__/0.0.0.0/g' web/lighttpd/lighttpd.conf > /etc/lighttpd/lighttpd.conf
yes | cp web/lighttpd/modules.conf /etc/lighttpd/modules.conf
sed 's|__socket__|/var/spool/dynamo/dynamoweb.sock|g' web/lighttpd/fastcgi.conf > /etc/lighttpd/conf.d/fastcgi.conf
sed 's|__certkeyfile__|/etc/pki/tls/certs/localhost.crt|g' web/lighttpd/ssl.conf | \
sed 's|__cafile__|/tmp/x509up_u500|g' | sed 's/ ssl.crl/# ssl.crl/g' > /etc/lighttpd/conf.d/ssl.conf
'''
}
}
stage ('Dynamo Installation') {
steps {
// Copy template files to proper location
sh '''
cp defaults.json.template defaults.json
cp dynamo.cfg.template dynamo.cfg
cp mysql/grants.json.template mysql/grants.json
'''
// Install Dynamo
sh 'printf "test\n" | ./install.sh'
// Need environment for whole thing
sh '''
source /usr/local/dynamo/etc/profile.d/init.sh
# Create dynamo user
yes | dynamo-user-auth --user dynamo --dn "/C=US/ST=Mass/L=Bahston/O=Dynamo/OU=test/CN=localhost" --role admin
dynamo-user-auth --user dynamo --role admin --target inventory
# Start server
dynamod &
sleep 3
# Authorize applications
dynamo-exec-auth -u dynamo -x $PWD/test/dynamo_setup.py --title setup
dynamo-exec-auth -u dynamo -x $PWD/test/dynamo_teardown.py --title teardown
'''
// Start lighttpd
sh '''
lighttpd -D -f /etc/lighttpd/lighttpd.conf &
sleep 2
'''
}
}
stage ('Unit Tests') {
steps {
sh 'cover=dynamo opsspace-test'
// Look at the results for debugging/confirmation
sh 'cat /var/log/dynamo/server.log'
}
}
stage ('Report Results') {
steps {
sh 'copy-coverage-html dynamo /html/coverage/${JOB_NAME}/${BUILD_NUMBER}'
}
}
}
}