-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
213 lines (196 loc) · 10.7 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/usr/bin/env groovy
node {
if (env.BRANCH_NAME.startsWith('PR')) {
return;
}
def image;
def currentStage;
def entryPoint = '-it';
try {
stage('Cleanup and Checkout') {
sh("echo Branch_name:${env.BRANCH_NAME}");
cleanWs();
checkout([
$class: 'GitSCM',
branches: [[name: "${env.BRANCH_NAME}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'Yorisoft', url: 'https://github.com/Yorisoft/puppet-purchase']]
])
}
currentStage = 'Build Image';
stage(currentStage) {
image = docker.build('puppet-purchase')
}
currentStage = 'Install npm';
stage(currentStage) {
image.inside(entryPoint) {
sh('npm install');
//sh ('npm i puppeteer --save');
sh('npm -v');
}
}
// currentStage = 'bestuy-bot-test';
// stage(currentStage) {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_BESTBUY', variable: 'TEST_USER_LISTING_URL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
// ]) {
// try{
// //echo("echo $TEST_USER_URL > $WORKSPACE/grr.txt"); //prints to test file (nick)
// sh('npm run bestbuy-bot-test')
// } catch (err){
// echo err.getMessage()
// throw err
// }
// }
// }
// }
// currentStage = 'target-bot-test';
// stage(currentStage) {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_TARGET', variable: 'TEST_USER_LISTING_URL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
// ]) {
// try{
// //echo("echo $TEST_USER_URL > $WORKSPACE/grr1.txt");
// sh('npm run target-bot-test');
// } catch (err){
// echo err.getMessage()
// throw err
// }
// }
// }
// }
parallel(
// My test user or ip keeps getting temporarily banned. Need solution for testing..
"bestuy-bot-test": {
image.inside(entryPoint) {
withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_BESTBUY', variable: 'TEST_USER_LISTING_URL'),
string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
]) {
try{
//echo("echo $TEST_USER_URL > $WORKSPACE/grr.txt"); //prints to test file (nick)
sh('npm run bestbuy-bot-test')
}
catch (err){
echo err.getMessage()
throw err
}
}
}
}
// "target-bot-test": {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_TARGET', variable: 'TEST_USER_LISTING_URL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
// ]) {
// try{
// //echo("echo $TEST_USER_URL > $WORKSPACE/grr1.txt");
// sh('npm run target-bot-test');
// }
// catch (err){
// echo err.getMessage()
// throw err
// }
// }
// }
// }
// "gamestop-bot-test": {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_GAMESTOP', variable: 'TEST_USER_LISTING_URL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL_PASSW', variable: 'TEST_USER_INBOX_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
// ]) {
// //echo("echo $TEST_USER_URL > $WORKSPACE/grr3.txt");
// sh('npm run gamestop-bot-test');
// }
// }
// },
// "micro-bot-test": {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_MICRO', variable: 'TEST_USER_LISTING_URL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL_PASSW', variable: 'TEST_USER_INBOX_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
// ]) {
// //echo("echo $TEST_USER_URL > $WORKSPACE/grr3.txt");
// sh('npm run micro-bot-test');
// }
// }
// },
// "newegg-bot-test": {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_NEWEGG', variable: 'TEST_USER_LISTING_URL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL_PASSW', variable: 'TEST_USER_INBOX_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
// ]) {
// //echo("echo $TEST_USER_URL > $WORKSPACE/grr2.txt");
// sh('npm run newegg-bot-test');
// }
// }
// },
// "walmart-bot-test": {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_URL_WALMART', variable: 'TEST_USER_LISTING_URL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL_PASSW', variable: 'TEST_USER_INBOX_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV'),
// ]) {
// //echo("echo $TEST_USER_URL > $WORKSPACE/grr3.txt");
// sh('npm run walmart-bot-test');
// }
// }
// }
)
//currentStage = 'all-bots-full-cycle test';
// stage(currentStage) {
// image.inside(entryPoint) {
// withCredentials([string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL', variable: 'TEST_USER_EMAIL'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_PASW', variable: 'TEST_USER_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_EMAIL_PASSW', variable: 'TEST_USER_EMAIL_PASSW'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_LOC', variable: 'TEST_USER_LOC'),
// string(credentialsId: 'PUPPET_PURCHASE_TEST_USER_CVV', variable: 'TEST_USER_CVV')
// ]) {
// }
// }
// }
}
catch (e) {
currentBuild.result = 'FAILURE';
throw e
}
finally {
stage('Create Archive'){
archiveArtifacts allowEmptyArchive: true, artifacts: '**', excludes: '**/node_modules/', followSymlinks: false;
//archiveArtifacts allowEmptyArchive: true, artifacts: 'record/screen_shots/newegg/*.png, record/screen_shots/bestbuy/*.png, record/screen_shots/target/*.png';
}
stage('cleanup'){
cleanWs();
sh('docker system prune -a -f');
}
}
}