-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
81 lines (78 loc) · 2.45 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
pipeline {
agent any
environment {
MONGO_PORT = '27018'
FLASK_ENV = 'dev'
CI = 'true'
REACT_APP_url = 'http://abedef.ddns.net:11801'
}
stages {
stage('Build') {
steps {
sh 'pip install pipenv'
script {
try {
sh 'docker stop jenkins_mongo'
} catch(error) {
echo 'OK'
}
try {
sh 'docker rm jenkins_mongo'
} catch(error) {
echo 'OK'
}
}
sh 'docker run -v jenkins-api-data:/data/db -p 27018:27017 -d --name jenkins_mongo mongo:xenial'
dir('APIService') {
sh 'pipenv install'
}
}
}
stage('Test') {
steps {
sh 'pip install --user pymongo'
sh 'python -c "import pymongo; print(pymongo.MongoClient(\\"localhost:27018\\").list_databases())"'
dir('APIService') {
sh 'pipenv run python -m unittest discover'
}
}
}
stage('ClientTest') {
steps {
dir('WebAppService') {
sh 'npm install'
sh 'npm test'
}
}
}
stage('Deploy') {
steps {
dir('APIService') {
sh 'docker-compose down'
sh 'docker-compose up -d'
}
dir('WebAppService') {
script {
try {
sh 'docker stop koolaid-client-staging'
} catch(error) {
echo 'OK'
}
try {
sh 'docker rm koolaid-client-staging'
} catch (error) {
echo 'OK'
}
}
sh 'docker build -t koolaid-client .'
sh 'docker run -p 3000:3000 -d --name koolaid-client-staging koolaid-client'
}
}
}
}
post {
always {
sh 'docker stop jenkins_mongo && docker rm jenkins_mongo'
}
}
}