-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
186 lines (150 loc) · 4.8 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import groovy.json.JsonBuilder
@Library('pipeline-library') _
def MAIN_BRANCH = 'master'
def DEVELOP_BRANCH = 'develop'
def isMain = {
env.BRANCH_NAME == MAIN_BRANCH
}
def isRelease = {
env.BRANCH_NAME.startsWith('release/')
}
def isDevelop = {
env.BRANCH_NAME == DEVELOP_BRANCH
}
def getBuildType = {
isMain()
? 'MAINLINE'
: 'FEATURE'
}
webappPipeline {
projectName = 'genesys-cloud-client-logger'
team = 'Client Streaming and Signaling'
jiraProjectKey = 'STREAM'
mailer = '[email protected]'
chatGroupId = '763fcc91-e530-4ed7-b318-03f525a077f6'
nodeVersion = '14.x'
buildType = getBuildType
manifest = customManifest('./dist') {
readJSON(file: 'dist/manifest.json')
}
snykConfig = {
return [
organization: 'genesys-client-media-webrtc'
]
}
deployConfig = [
dev : 'always',
test : 'always',
prod : 'always',
'fedramp-use2-core': 'always'
]
autoSubmitCm = true
testJob = 'no-tests' // see buildStep to spigot tests
ciTests = {
println("""
========= BUILD VARIABLES =========
ENVIRONMENT : ${env.ENVIRONMENT}
BUILD_NUMBER : ${env.BUILD_NUMBER}
BUILD_ID : ${env.BUILD_ID}
BRANCH_NAME : ${env.BRANCH_NAME}
APP_NAME : ${env.APP_NAME}
VERSION : ${env.VERSION}
===================================
""")
sh("""
npm i -g npm@7
npm ci
npm run test
""")
}
buildStep = {cdnUrl ->
sh("""
echo 'CDN_URL ${cdnUrl}'
npm --versions
npm run build
""")
}
onSuccess = {
sh("""
echo "=== root folder ==="
ls -als ./
echo "=== Printing manifest.json ==="
cat ./manifest.json
echo "=== Printing package.json ==="
cat ./package.json
echo "=== dist folder ==="
ls -als dist/
echo "=== Printing dist/deploy-info.json ==="
cat ./dist/deploy-info.json
# echo "=== Printing dist/package.json ==="
# cat ./dist/package.json
""")
// NOTE: this version only applies to the npm version published and NOT the cdn publish url/version
def version = env.VERSION
def packageJsonPath = "./package.json"
def tag = ""
// save a copy of the original package.json
// sh("cp ${packageJsonPath} ${packageJsonPath}.orig")
// if not MAIN branch, then we need to adjust the verion in the package.json
if (!isMain()) {
// load the package.json version
def packageJson = readJSON(file: packageJsonPath)
def featureBranch = env.BRANCH_NAME
// all feature branches default to --alpha
tag = "alpha"
if (isRelease()) {
tag = "next"
featureBranch = "release"
}
if (isDevelop()) {
tag = "beta"
featureBranch = "develop"
}
version = "${packageJson.version}-${featureBranch}.${env.BUILD_NUMBER}".toString()
}
def npmFunctions = null
def gitFunctions = null
def pwd = pwd()
stage('Download npm & git utils') {
script {
// clone pipelines repo
dir('pipelines') {
git branch: 'COMUI-857',
url: '[email protected]:inindca/pipeline-library.git',
changelog: false
npmFunctions = load 'src/com/genesys/jenkins/Npm.groovy'
gitFunctions = load 'src/com/genesys/jenkins/Git.groovy'
}
}
} // end download pipeline utils
stage('Publish to NPM') {
script {
dir(pwd) {
npmFunctions.publishNpmPackage([
tag: tag, // optional
useArtifactoryRepo: false, // optional, default `true`
version: version, // optional, default is version in package.json
dryRun: false // dry run the publish, default `false`
])
}
}
} // end publish to npm
if (isMain()) {
stage('Tag commit and merge main branch back into develop branch') {
script {
gitFunctions.tagCommit(
"v${version}",
gitFunctions.getCurrentCommit(),
false
)
gitFunctions.mergeBackAndPrep(
MAIN_BRANCH,
DEVELOP_BRANCH,
'patch',
false
)
}
} // end tag commit and merge back
} // isMain()
} // onSuccess
} // end