-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
142 lines (128 loc) · 4.18 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
pipeline {
agent any
options {
disableConcurrentBuilds()
timestamps()
timeout(time: 5, unit: 'HOURS')
}
parameters {
string(
name: 'DOCKER_HOST_IP',
description: 'Docker Host IP',
defaultValue: '192.168.2.20'
)
string(
name: 'DOCKER_TCP_PORT',
description: 'Docker host TCP port',
defaultValue: '2375'
)
string(
name: 'NEXUS_URL',
description: 'Nexus base URL',
defaultValue: 'http://192.168.2.20:8001/nexus'
)
string(
name: 'POSTMAN_ENVIRONMENT',
description: 'Postman environment configuration',
defaultValue: 'local.postman_environment.json'
)
}
environment {
DOCKER_HOST_URL = "tcp://${DOCKER_HOST_IP}:${DOCKER_TCP_PORT}"
URL_ENRON_INDEXER = "${NEXUS_URL}/service/local/artifact/maven/redirect?r=snapshots&g=com.enron.indexer&a=enron_indexer&v=LATEST"
URL_ENRON_WEB = "${NEXUS_URL}/service/local/artifact/maven/redirect?r=snapshots&g=com.enron.web&a=enron_web&v=LATEST"
}
stages {
stage('Preparation') {
steps {
sh "curl -o ./enron_indexer/enron_indexer.jar -L '${URL_ENRON_INDEXER}'"
sh "curl -o ./enron_web/enron_web.jar -L '${URL_ENRON_WEB}'"
}
}
stage("Start SlasticSearch container") {
steps {
script {
docker.withServer("${DOCKER_HOST_URL}") {
esContainer = docker.image('elasticsearch:2.4.5-alpine').run('-p 9200:9200 -p 9300:9300');
sleep 5
}
}
}
}
stage("Create Enron Indexer Container") {
steps {
script {
docker.withServer("${DOCKER_HOST_URL}") {
indexerImage = docker.build("enron_indexer", "./enron_indexer");
}
}
}
}
stage("Run Enron Indexer Container") {
steps {
script {
docker.withServer("${DOCKER_HOST_URL}") {
indexerImage.withRun('-e ES_HOST=http://${DOCKER_HOST_IP}:9200') {c ->
sleep 5
sh "docker logs ${c.id}"
}
}
}
}
}
stage("Create Enron Web Container") {
steps {
script {
docker.withServer("${DOCKER_HOST_URL}") {
webImage = docker.build("enron_web", "./enron_web");
}
}
}
}
stage("Run Enron Web Container") {
steps {
script {
docker.withServer("${DOCKER_HOST_URL}") {
webContainer = webImage.run('-p 9000:9000 -e ES_HOST=${DOCKER_HOST_IP}');
sleep 5
sh "docker logs ${webContainer.id}"
}
}
}
}
stage("Run Postman Tests") {
steps {
script {
sh "newman run ./enron_web/enron.postman_collection.json -e ./enron_web/${POSTMAN_ENVIRONMENT} -r html"
}
archiveArtifacts artifacts: 'newman/*.html'
}
}
stage("Waiting for user...") {
steps {
input 'Continue?'
}
}
}
post {
always {
cleanWs()
script {
docker.withServer("${DOCKER_HOST_URL}") {
try {
webContainer.stop();
}
catch (e) {
echo 'Fail to stop Enron Web Container!'
}
try {
esContainer.stop();
}
catch (e) {
echo 'Fail to stop ElasticSearch Container!'
}
}
}
}
}
}