forked from hypothesis/h
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·74 lines (61 loc) · 2.19 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
#!groovy
@Library('pipeline-library') _
def img
node {
stage('build') {
checkout(scm)
img = buildApp(name: 'hypothesis/hypothesis')
}
stage('test') {
hostIp = sh(script: 'facter ipaddress_eth0', returnStdout: true).trim()
postgres = docker.image('postgres:9.4').run('-P -e POSTGRES_DB=htest')
databaseUrl = "postgresql://postgres@${hostIp}:${containerPort(postgres, 5432)}/htest"
elasticsearch = docker.image('hypothesis/elasticsearch').run('-P -e "discovery.type=single-node"')
elasticsearchHost = "http://${hostIp}:${containerPort(elasticsearch, 9200)}"
rabbit = docker.image('rabbitmq').run('-P')
brokerUrl = "amqp://guest:guest@${hostIp}:${containerPort(rabbit, 5672)}//"
try {
testApp(image: img, runArgs: "-u root " +
"-e BROKER_URL=${brokerUrl} " +
"-e ELASTICSEARCH_URL=${elasticsearchHost} " +
"-e TEST_DATABASE_URL=${databaseUrl}") {
// Test dependencies
sh 'apk add --no-cache build-base libffi-dev postgresql-dev python-dev'
sh 'apk add --no-cache python3 python3-dev'
sh 'pip install -q tox'
// Unit tests
sh 'cd /var/lib/hypothesis && tox'
// Functional tests
sh 'cd /var/lib/hypothesis && tox -e functional'
sh 'cd /var/lib/hypothesis && tox -e functional-py36'
}
} finally {
rabbit.stop()
elasticsearch.stop()
postgres.stop()
}
}
onlyOnMaster {
stage('release') {
releaseApp(image: img)
}
}
}
onlyOnMaster {
milestone()
stage('qa deploy') {
deployApp(image: img, app: 'h', env: 'qa')
}
milestone()
stage('prod deploy') {
input(message: "Deploy to prod?")
milestone()
deployApp(image: img, app: 'h', env: 'prod')
}
}
def containerPort(container, port) {
return sh(
script: "docker port ${container.id} ${port} | cut -d: -f2",
returnStdout: true
).trim()
}