This repository has been archived by the owner on Dec 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Jenkinsfile
60 lines (52 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
51
52
53
54
55
56
57
58
59
60
node('docker') {
def img
def version
def commit
def artifactName
def extName = "re_consent"
def s3BasePath = "cdncliqz/update/re-consent"
stage ('Checkout') {
def checkoutInfo = checkout scm
commit = checkoutInfo.GIT_COMMIT
}
stage('Build Docker Image') {
img = docker.build('reconsent/build', '--build-arg UID=`id -u` --build-arg GID=`id -g` .')
}
stage('Build Extension') {
img.inside() {
version = sh(returnStdout: true, script: 'node -p "require(\'./package.json\').version"').trim()
sh 'cp -R /app/node_modules ./'
sh 'npm run build'
}
}
stage('Upload Artifact') {
// tag artifact with commit id
artifactName = "${extName}-${version}-${commit.substring(0, 7)}.zip"
def uploadLocation = "s3://${s3BasePath}/${env.BRANCH_NAME}/${artifactName}"
currentBuild.description = uploadLocation
sh "mv build/${extName}-${version}.zip build/${artifactName}"
withS3Credentials {
sh "aws s3 cp build/${artifactName} ${uploadLocation} --acl public-read"
}
}
if (env.BRANCH_NAME == 'master') {
stage('Sign Extension') {
def artifactUrl = "https://s3.amazonaws.com/${s3BasePath}/${env.BRANCH_NAME}/${artifactName}"
build job: 'addon-repack', parameters: [
string(name: 'XPI_URL', value: artifactUrl),
string(name: 'XPI_SIGN_CREDENTIALS', value: '41572f9c-06aa-46f0-9c3b-b7f4f78e9caa'),
string(name: 'XPI_SIGN_REPO_URL', value: 'git@github.com:cliqz/xpi-sign.git'),
string(name: 'CHANNEL', value: 'browser')
]
}
}
}
def withS3Credentials(Closure body) {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: '06ec4a34-9d01-46df-9ff8-64c79eda8b14',
passwordVariable: 'AWS_SECRET_ACCESS_KEY',
usernameVariable: 'AWS_ACCESS_KEY_ID']]) {
body()
}
}