-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
84 lines (76 loc) · 2.76 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
// Define an empty map for storing remote SSH connection parameters
def remote = [:]
pipeline {
agent any
environment {
user = credentials('fertalizer_user')
host = credentials('fertalizer_host')
name = credentials('fertalizer_name')
ssh_key = credentials('fertalizer_devops')
}
stages {
stage('Ssh to connect Tesla server') {
steps {
script {
// Set up remote SSH connection parameters
remote.allowAnyHosts = true
remote.identityFile = ssh_key
remote.user = user
remote.name = name
remote.host = host
}
}
}
stage('Download latest release') {
steps {
script {
sshCommand remote: remote, command: """
cd /var/www/docs/webapi/
sudo kill -9 \$(sudo netstat -nepal | grep 5000 | awk '{print \$9}' | awk -F '/' '{print \$1}')
rm -fr api_backup_\$(date +"%Y%m%d")
mv api api_backup_\$(date +"%Y%m%d")
rm -fr releaseApi.zip
curl -LOk https://github.com/CIAT-DAPA/ethiopia_fertilize_system/releases/latest/download/releaseApi.zip
unzip -o releaseApi.zip
rm -fr releaseApi.zip
mv src/webapi/* api
rm -fr src
"""
}
}
}
stage('Init Api') {
steps {
script {
sshCommand remote: remote, command: """
cd /var/www/docs/webapi/
source env/bin/activate
export DEBUG=False
export WORKSPACE=fertilizer_et
export LAYER_NAME=:et_wheat_fertilizer_recommendation_normal
export SERVICE=WFS
export GEOSERVER_URL="https://geo.aclimate.org/geoserver/"
export FERTILIZER_RASTERS_DIR="./raster_files/cropped/"
export PORT=5000
export CONNECTION_DB=mongodb://localhost:27017/nextgen_db
export HOST=0.0.0.0
cd api/
nohup python agroadvisory_api.py > log.txt 2>&1 &
"""
}
}
}
}
post {
failure {
script {
echo 'fail'
}
}
success {
script {
echo 'everything went very well!!'
}
}
}
}