-
Notifications
You must be signed in to change notification settings - Fork 71
/
Jenkinsfile
70 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
def testReport = 'test-report.xml'
def stagingBucket = 'internal.clyqz.com'
def stagingPrefix = '/docs/whotracksme'
def productionBucket = 'whotracksme'
def productionPrefix = ''
node('magrathea') {
stage ('Checkout') {
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
extensions: [[$class: 'GitLFSPull']],
userRemoteConfigs: [
[refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/PR-* +refs/tags/*:refs/remotes/origin/*',
url: 'https://github.com/ghostery/whotracks.me.git']
]
])
}
def img
stage('Download Datasets') {
dir('whotracksme/data/assets') {
sh('aws s3 sync --no-sign-request --no-progress s3://data.whotracks.me/ .')
}
}
stage('Build Docker Image') {
img = docker.build('whotracksme', '. --build-arg user=`whoami` --build-arg UID=`id -u` --build-arg GID=`id -g`')
}
img.inside() {
try {
stage('Install') {
sh("python -m pip install --user -e '.[dev]'")
}
stage('Test') {
try {
sh(script: "pytest --junit-xml=${testReport}")
} catch(err) {
junit(testReport)
currentBuild.result = "FAILURE"
}
}
stage('Build site') {
sh('/home/jenkins/.local/bin/whotracksme website')
}
if (env.BRANCH_NAME == 'master') {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: '04e892d6-1f78-400e-9908-1e9466e238a9',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]]) {
stage('Publish Site') {
sh("python deploy_to_s3.py ${productionBucket} ${productionPrefix} --production")
}
}
}
} finally {
// cleanup
sh('rm -rf _site; rm -rf .sass-cache')
}
}
junit(testReport)
}