forked from thezedwards/autoconsent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
50 lines (42 loc) · 2 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
properties([
parameters([
choice(name: 'CHANNEL', defaultValue: 'staging', choices: 'staging\nproduction')
]),
])
node('docker && !gpu') {
def img
def commitHash
stage('Checkout') {
checkout scm
commitHash = sh(returnStdout: true, script: 'git log --pretty=format:\'%h\' -n 1').trim()
currentBuild.description = "${commitHash}-${params.CHANNEL}"
}
stage('Build Docker Image') {
img = docker.build('autoconsent/build')
}
img.inside() {
stage('Build') {
sh 'cp -r /app/node_modules ./'
sh 'npm run bundle'
}
stage('Build rules') {
sh 'node rules/build.js'
sh 'rm -f rules/rules.min.*'
sh "jq -c '. + { version: \"${commitHash}\" }' rules/rules.json > rules/rules.min.json"
sh 'brotli --input rules/rules.min.json --output rules/rules.min.json.br'
sh "gzip -9 rules/rules.min.json"
}
}
if (env.BRANCH_NAME == 'master') {
stage('Publish') {
sh "aws s3 cp rules/rules.min.json.br s3://cdn.cliqz.com/autoconsent/rules/${commitHash}.json.br --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-encoding br --content-type application/json --cache-control \"immutable\""
sh "aws s3 cp rules/rules.min.json.gz s3://cdn.cliqz.com/autoconsent/rules/${commitHash}.json.gz --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-encoding gzip --content-type application/json --cache-control \"immutable\""
sh "echo '{\"ruleVersion\":\"${commitHash}\",\"disabled\":[]}' > config.json"
def fileName = 'config.json'
if (params.CHANNEL == 'staging') {
fileName = 'staging-config.json'
}
sh "aws s3 cp config.json s3://cdn.cliqz.com/autoconsent/${fileName} --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json --cache-control \"max-age=3600\""
}
}
}