forked from whotracksme/whotracks.me
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
58 lines (49 loc) · 1.56 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
def testReport = 'test-report.xml'
def stagingBucket = 'internal.clyqz.com'
def stagingPrefix = '/docs/whotracksme'
def productionBucket = 'cliqz-tracking-monitor'
def productionPrefix = ''
node('docker') {
stage ('Checkout') {
retry(5) {
checkout scm
}
}
def img
stage('Build Docker Image') {
img = docker.build('whotracksme', '.')
}
img.inside('-u 0:0') {
try {
stage('Install') {
sh("python -m pip install '.[test,website]'")
}
stage('Test') {
try {
sh(script: "pytest --junit-xml=${testReport}")
} catch(err) {
junit(testReport)
currentBuild.result = "FAILURE"
}
}
stage('Build site') {
sh('whotracksme website')
}
stage('Publish Site') {
def deployArgs = ''
if (env.BRANCH_NAME.contains('PR')) {
deployArgs = "${stagingBucket} ${stagingPrefix}/${env.BRANCH_NAME}"
} else if (env.BRANCH_NAME == 'production') {
deployArgs = "${productionBucket} ${productionPrefix} --production"
} else {
deployArgs = "${stagingBucket} ${stagingPrefix}/latest"
}
sh("python deploy_to_s3.py ${deployArgs}")
}
} finally {
// cleanup
sh('rm -rf _site; rm -rf .sass-cache')
}
}
junit(testReport)
}