Skip to content

Commit 8f1ada1

Browse files
authored
Merge pull request #13 from CIAT-DAPA/develop
added pipeline to jenkinsfile
2 parents 51da5f3 + c07311a commit 8f1ada1

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

jenkinsfile

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Define an empty map for storing remote SSH connection parameters
2+
def remote = [:]
3+
4+
pipeline {
5+
6+
agent any
7+
8+
environment {
9+
user = credentials('wp_user')
10+
host = credentials('wp_host')
11+
name = credentials('wp_name')
12+
ssh_key = credentials('wp_devops')
13+
}
14+
15+
stages {
16+
stage('Ssh to connect Bigelow server') {
17+
steps {
18+
script {
19+
// Set up remote SSH connection parameters
20+
remote.allowAnyHosts = true
21+
remote.identityFile = ssh_key
22+
remote.user = user
23+
remote.name = name
24+
remote.host = host
25+
26+
}
27+
}
28+
}
29+
stage('Download latest release') {
30+
steps {
31+
script {
32+
sshCommand remote: remote, command: """
33+
cd /var/www/waterpointsapi/
34+
sudo kill -9 $(sudo ss -tuln | grep ':5000' | awk '{print $5}' | cut -d ':' -f 1)
35+
rm -fr api_backup_\$(date +"%Y%m%d")
36+
mv api api_backup_\$(date +"%Y%m%d")
37+
rm -fr releaseApi.zip
38+
curl -LOk https://github.com/CIAT-DAPA/lswms_webapi/releases/latest/download/releaseApi.zip
39+
unzip -o releaseApi.zip
40+
rm -fr releaseApi.zip
41+
mkdir api
42+
mv src/* api
43+
rm -fr src
44+
"""
45+
}
46+
}
47+
}
48+
stage('Init Api') {
49+
steps {
50+
script {
51+
sshCommand remote: remote, command: """
52+
cd /var/www/waterpointsapi/
53+
export DEBUG=False
54+
export PORT=5000
55+
export CONNECTION_DB=mongodb://localhost:27017/waterpoints
56+
export HOST=0.0.0.0
57+
cd api/
58+
nohup python wpapi.py > log.txt 2>&1 &
59+
"""
60+
}
61+
}
62+
}
63+
}
64+
65+
post {
66+
failure {
67+
script {
68+
echo 'fail'
69+
}
70+
}
71+
72+
success {
73+
script {
74+
echo 'everything went very well!!'
75+
}
76+
}
77+
}
78+
79+
}

0 commit comments

Comments
 (0)