-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
106 lines (97 loc) · 3.28 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
// Define an empty map for storing remote SSH connection parameters
def remote = [:]
pipeline {
agent any
environment {
server_name = credentials('wp_name')
server_host = credentials('wp_host')
ssh_key = credentials('wp_devops')
}
stages {
stage('Ssh to connect bigelow server') {
steps {
script {
// Set up remote SSH connection parameters
remote.allowAnyHosts = true
remote.identityFile = ssh_key
remote.user = ssh_key_USR
remote.name = server_name
remote.host = server_host
}
}
}
stage('Download latest release and create enviroment') {
steps {
script {
sshCommand remote: remote, command: """
cd /var/www/waterpointsApi
if [ ! -d api_WP ]; then
mkdir ./api_WP
fi
cd /var/www/waterpointsApi/api_WP
rm -rf env
rm -rf src
kill -9 \$(lsof -t -i:5001)
curl -LOk https://github.com/CIAT-DAPA/lswms_webapi/releases/latest/download/releaseApi.zip
unzip -o releaseApi.zip
rm -fr releaseApi.zip
python3 -m venv env
"""
}
}
}
stage(' activate enviroment and install requirements') {
steps {
script {
sshCommand remote: remote, command: """
cd /var/www/waterpointsApi/api_WP
source env/bin/activate
cd src
pip install -r requirements.txt
"""
}
}
}
stage('Init api') {
steps {
script {
sshCommand remote: remote, command: """
cd /var/www/waterpointsApi/api_WP
source env/bin/activate
cd src
export DEBUG=False
export API_WP_PORT=5001
export CONNECTION_DB=mongodb://localhost:27017/waterpoints
export HOST=0.0.0.0
export API_KEY=\$(cat /var/www/key.txt)
nohup python3 wpapi.py > log.txt 2>&1 &
"""
}
}
}
stage('Run Seeder File') {
steps {
script {
sshCommand remote: remote, command: """
cd /var/www/waterpointsApi/api_WP
source env/bin/activate
cd src/seeder
python3 woredas_seeder.py
"""
}
}
}
}
post {
failure {
script {
echo 'fail'
}
}
success {
script {
echo 'everything went very well, api in production'
}
}
}
}