Skip to content

Commit 54c4b6b

Browse files
cybersource-tpiKrishna Prasad
and
Krishna Prasad
authored
Updated code version of 22.1.0 (#2)
Co-authored-by: Krishna Prasad <[email protected]>
1 parent 9e8e970 commit 54c4b6b

File tree

446 files changed

+20571
-15046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

446 files changed

+20571
-15046
lines changed

Jenkinsfile

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env groovy
2+
3+
@Library('tkutils')
4+
import tk.jenkins.common.*
5+
import static tk.jenkins.slack.SlackNotify.notifySlack
6+
7+
def podLabel = UUID.randomUUID().toString()
8+
9+
def gitBranch = 'unknown'
10+
11+
podTemplate(
12+
label: podLabel,
13+
yaml: PodSecurityContext.ROOT,
14+
containers: [
15+
containerTemplate(
16+
name: 'node',
17+
image: 'docker.io/node:14.19.0',
18+
alwaysPullImage: true,
19+
ttyEnabled: true,
20+
command: 'cat',
21+
workingDir: '/home/jenkins/agent',
22+
resourceRequestCpu: '500m',
23+
resourceRequestMemory: '5120Mi',
24+
resourceLimitMemory: '5120Mi',
25+
)
26+
],
27+
volumes: [
28+
secretVolume(mountPath: '/secrets', secretName: 'jenkins-service-account')
29+
]
30+
)
31+
32+
{
33+
node(podLabel) {
34+
35+
try {
36+
currentBuild.result = 'SUCCESS'
37+
gitBranch = GitHelper.getCurrentBranch(this)
38+
print "checking out '${gitBranch}' branch..."
39+
40+
stage('checkout') {
41+
checkout scm
42+
}
43+
44+
stage('install') {
45+
container('node') {
46+
sh 'yarn install'
47+
}
48+
}
49+
50+
stage('build') {
51+
container('node') {
52+
sh 'yarn build'
53+
}
54+
}
55+
56+
stage('checks & tests') {
57+
container('node') {
58+
sh 'yarn ci'
59+
}
60+
}
61+
62+
stage('coverage') {
63+
container('node') {
64+
parallel(
65+
'unit': {
66+
sh 'yarn test:coverage:unit'
67+
},
68+
'int': {
69+
sh 'yarn test:coverage:int'
70+
}
71+
)
72+
}
73+
}
74+
} catch (any) {
75+
currentBuild.result = 'FAILURE'
76+
throw any
77+
} finally {
78+
publishHTML(target: [
79+
allowMissing : true,
80+
alwaysLinkToLastBuild: true,
81+
keepAll : true,
82+
reportDir : './html-reports',
83+
reportFiles : 'lint-report.html',
84+
reportTitles : 'ESLint',
85+
reportName : 'ESLint Report'
86+
])
87+
88+
publishHTML(target: [
89+
allowMissing : true,
90+
alwaysLinkToLastBuild: true,
91+
keepAll : true,
92+
reportDir : '.',
93+
reportFiles : """packages/payment-widget/html-reports/jest-report.html, \
94+
packages/server-extension/html-reports/int/jest-report.html, \
95+
packages/server-extension/html-reports/unit/jest-report.html""",
96+
reportTitles : 'Widget, Server-Int, Server-Unit',
97+
reportName : 'Test Reports'
98+
])
99+
100+
publishHTML(target: [
101+
allowMissing : true,
102+
alwaysLinkToLastBuild: true,
103+
keepAll : true,
104+
reportDir : '.',
105+
reportFiles : """packages/payment-widget/html-reports/coverage/index.html, \
106+
packages/server-extension/html-reports/int/coverage/index.html, \
107+
packages/server-extension/html-reports/unit/coverage/index.html""",
108+
reportTitles : 'Widget, Server-Int, Server-Unit',
109+
reportName : 'Code Coverage Reports'
110+
])
111+
112+
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: '[email protected]'])
113+
notifySlack(this, "cybersource-jenkins", false)
114+
}
115+
}
116+
}

Jenkinsfile.publish

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/usr/bin/env groovy
2+
3+
@Library('tkutils')
4+
import static tk.jenkins.slack.SlackNotify.notifySlack
5+
import tk.jenkins.common.*
6+
7+
def podLabel = UUID.randomUUID().toString()
8+
def deployWidgets = JobParameter.getBoolean(this, 'deployWidgets', false)
9+
def deploySSE = JobParameter.getBoolean(this, 'deploySSE', false)
10+
def deployGateway = JobParameter.getBoolean(this, 'deployGateway', false)
11+
12+
def widgetNames = JobParameter.get(this, 'widgetNames', 'payment-widget,saved-cards-widget')
13+
def appName = JobParameter.get(this, 'appName', 'osf-payment-sse')
14+
def gatewayName = JobParameter.get(this, 'gatewayName', 'payment-gateway')
15+
16+
def settingsPayload = JobParameter.get(this, 'settingsPayload', 'packages/payment-gateway/settings.json')
17+
18+
def gitBranch = 'unknown'
19+
20+
podTemplate(
21+
label: podLabel,
22+
yaml: PodSecurityContext.ROOT,
23+
containers: [
24+
containerTemplate(
25+
name: 'node',
26+
image: 'node:10.18.0',
27+
alwaysPullImage: true,
28+
ttyEnabled: true,
29+
command: 'cat',
30+
workingDir: '/home/jenkins/agent',
31+
resourceRequestCpu: '500m',
32+
resourceRequestMemory: '5120Mi',
33+
resourceLimitMemory: '5120Mi',
34+
)
35+
],
36+
volumes: [
37+
secretVolume(mountPath: '/secrets', secretName: 'jenkins-service-account')
38+
]
39+
)
40+
41+
{
42+
node(podLabel) {
43+
44+
try
45+
{
46+
currentBuild.result = 'SUCCESS'
47+
gitBranch = GitHelper.getCurrentBranch(this)
48+
print "checking out '${gitBranch}' branch..."
49+
50+
withCredentials([
51+
usernamePassword(
52+
credentialsId: 'isv_occ_sse',
53+
usernameVariable: 'url',
54+
passwordVariable: 'occ_key'),
55+
usernamePassword(
56+
credentialsId: 'isv_occ_widget',
57+
usernameVariable: 'occ_user',
58+
passwordVariable: 'occ_pwd')]) {
59+
60+
stage('checkout') {
61+
checkout scm
62+
}
63+
64+
stage('install') {
65+
container('node') {
66+
sh 'yarn install'
67+
}
68+
}
69+
70+
stage('build') {
71+
container('node') {
72+
sh 'yarn build'
73+
}
74+
}
75+
76+
stage('build:prod') {
77+
container('node') {
78+
dir('packages/server-extension') {
79+
sh 'yarn build:prod'
80+
}
81+
82+
dir('packages/payment-widget') {
83+
sh 'yarn build:prod'
84+
}
85+
86+
dir('packages/saved-cards-widget') {
87+
sh 'yarn build:prod'
88+
}
89+
}
90+
}
91+
92+
stage('package and upload application') {
93+
if (deploySSE)
94+
{
95+
container('node') {
96+
sh "yarn occ package-app ${appName}"
97+
sh "yarn occ upload-app -u ${url} -k ${occ_key} ${appName}"
98+
}
99+
} else {
100+
echo 'Skip server-side extension deploy'
101+
}
102+
}
103+
104+
stage('package and upload widget') {
105+
if (deployWidgets)
106+
{
107+
container('node') {
108+
widgetNames.split(',').each { widget ->
109+
def widgetId = sh (
110+
returnStdout: true,
111+
script: """yarn occ find-extension-id -u ${url} -k ${occ_key} ${widget} | awk 'BEGIN{ RS = ""; FS = "\\n" } {print \$5; exit}'""").trim()
112+
113+
sh "yarn occ deactivate-extension -u ${url} -k ${occ_key} -e ${widgetId} ${widget}"
114+
115+
sh "yarn occ upload-extension -x html-reports,widget/isv-occ-payment/js/__tests__,widget/saved-cards/js/__tests__ -u ${url} -k ${occ_key} ${widget}"
116+
}
117+
}
118+
} else {
119+
echo 'Skip widgets deploy'
120+
}
121+
}
122+
123+
stage('package and upload gateway settings') {
124+
if (deployGateway)
125+
{
126+
container('node') {
127+
def gatewayId = sh (
128+
returnStdout: true,
129+
script: """yarn occ find-extension-id -u ${url} -k ${occ_key} ${gatewayName} | awk 'BEGIN{ RS = ""; FS = "\\n" } {print \$5; exit}'""").trim()
130+
sh "yarn occ deactivate-extension -u ${url} -k ${occ_key} -e ${gatewayId} ${gatewayName}"
131+
132+
sh "yarn occ package-extension ${gatewayName}"
133+
sh "yarn occ upload-extension -u ${url} -k ${occ_key} ${gatewayName}"
134+
135+
stage('set settings') {
136+
sh "yarn occ settings:set -u ${url} -k ${occ_key} isv-occ-gateway '${settingsPayload}'"
137+
}
138+
}
139+
} else {
140+
echo 'Skip payment gateway deploy'
141+
}
142+
}
143+
} // withCredentials
144+
} catch (any) {
145+
currentBuild.result = 'FAILURE'
146+
throw any
147+
} finally {
148+
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: '[email protected]'])
149+
notifySlack(this, "cybersource-jenkins", false)
150+
}
151+
}}

0 commit comments

Comments
 (0)