-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main Smoke & regression pipeline
189 lines (115 loc) · 3.79 KB
/
Main Smoke & regression pipeline
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
187
188
189
pipeline {
agent {
node {
label "built-in"
}
}
post {
failure {
updateGitlabCommitStatus name: 'build failed', state: 'failed'
}
success {
updateGitlabCommitStatus name: 'build passed', state: 'success'
}
aborted {
updateGitlabCommitStatus name: 'build aborted', state: 'canceled'
}
}
options {
gitLabConnection('Derivaz')
}
triggers {
gitlab(triggerOnMergeRequest: true, branchFilterType: 'All')
}
stages {
stage('Checkout') {
steps {
sh "sudo rm -rf *"
git url: "${gitlabSourceRepoURL}", branch: '${gitlabSourceBranch}'
}
}
stage ('Parallel-stages') {
parallel {
stage ('Building the code') {
steps {
//build 'DRI_frontend_build_for_jenkins'
sh '''
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
ng --version
npm cache clean --force
sudo rm -rf node_modules
sudo rm -rf package-lock.json
npm i
npm run build --prod --aot --output-hashing=all
cd dist/osians/
sudo tar -cvf build.tar browser
sudo cp build.tar /var/lib/jenkins/workspace/Webhook_test/
'''
}
}
stage ('Sonarqube analysis') {
steps {
dir ('/var/lib/jenkins/barclays') {
sh "sudo rm -rf *"
sh "sudo cp -R /var/lib/jenkins/workspace/Webhook_test/* ." //copying the checkout files to another directory and running sonar scan because it installs its own node dependencies that coincides with the node_modules directory when executed from the same location
sh "sudo npm install sonar-scanner --save-dev"
sh "sudo npm run sonar"
sh "date"
}
}
}
}
}
stage ('Extracting latest build'){
steps {
dir ('/var/lib/jenkins/workspace/Webhook_test') {
sh "sudo tar xvf build.tar"
sh "date"
}
}
}
stage ('Copying config file & Dockerfile'){
steps {
dir ('/var/lib/jenkins/workspace/Webhook_test/browser') {
sh "sudo cp /var/lib/jenkins/workspace/DETAILS101/browser/config ."
sh "sudo cp /var/lib/jenkins/workspace/DETAILS101/browser/Dockerfile ."
sh "date"
}
}
}
stage ('Docker login, Docker image & environment') {
steps {
dir ('/var/lib/jenkins/workspace/Webhook_test/browser') {
sh "sudo docker rmi nupur204/test:2.0"
sh "sudo docker rmi -f derivaz_front:1.0"
sh "sudo docker build -t derivaz_front:1.0 ."
sh "sudo docker tag derivaz_front:1.0 nupur204/test:2.0"
sh "sudo docker run -itd --name derivaz_Frontend -p 9090:80 nupur204/test:2.0"
sh "date"
}
}
}
stage ('Cypress containerized test') {
agent {
node {
label "10.0.4.17"
}
}
steps {
sh "sudo docker run cyder:1.6 npx cypress run --env ENV='test',TAGS='@smoketest' --spec '**/**/login.feature'"
sh "sudo docker run cyder:1.6 npx cypress run --env ENV='test',TAGS='@smoke' --spec '**/**/header.feature'"
sh "sudo docker run cyder:1.6 npx cypress run --env ENV='test',TAGS='@smoke' --spec '**/**/footer.feature'"
sh "date"
}
}
stage ('Deletion of Environments') {
steps {
sh "sudo docker stop derivaz_Frontend"
sh "sudo docker rm derivaz_Frontend"
sh "date"
}
}
}
}