forked from freshworks/crayons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
94 lines (79 loc) · 2.31 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!groovy
def runNPM(command) {
def NODE_VERSION = 16;
utilObj = new Utils();
envVersion = utilObj.getEnvVersion(NODE_VERSION);
utilObj.runCmd(command, envVersion)
}
def uploadAndInvalidate(environment) {
def STATIC_ASSETS = [
staging: [
bucketName: 'static.freshcloud.io',
cdnDistributionId: 'E1NTINA3EQZS8T',
profile: 'default'
],
release: [
bucketName: 'crayon-freshworks',
cdnDistributionId: 'E2L2PEITWYW1LM',
profile: 'prod'
]
]
uploadAssetsToS3('www-dist', "s3://${STATIC_ASSETS[environment].bucketName}", 'us-east-1', true, false, 86400, STATIC_ASSETS[environment].profile)
uploadAssetsToS3('docs/storybook-dist', "s3://${STATIC_ASSETS[environment].bucketName}/storybook", 'us-east-1', true, false, 86400, STATIC_ASSETS[environment].profile)
invalidateCDN(STATIC_ASSETS[environment].cdnDistributionId, '\"/*\"', STATIC_ASSETS[environment].profile)
}
pipeline {
agent any
parameters {
choice(choices: 'None\nstaging\nrelease', description: 'Deploys the UI Kit to Staging or Release', name: 'deployTo')
}
stages {
stage('Checkout & Setup') {
steps {
checkout scm
runNPM('HUSKY_SKIP_INSTALL=1 npm ci')
}
}
stage ('Code Sanity') {
steps {
runNPM('npm run code-sanity')
}
}
stage ('Tests') {
steps {
runNPM('npm run test')
}
}
stage ('Build') {
steps {
runNPM('npm run build')
}
}
stage ('Deploy to Staging') {
when {
expression {
params.deployTo == 'staging' && (BRANCH_NAME == 'master' || BRANCH_NAME == 'next')
}
}
steps {
uploadAndInvalidate('staging')
}
}
stage ('Deploy to Release') {
when {
expression {
params.deployTo == 'release' && (BRANCH_NAME == 'master' || BRANCH_NAME == 'next')
}
}
steps {
uploadAndInvalidate('release')
}
}
}
post {
always {
sendEmail()
deleteDir()
}
}
}