forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselenium.groovy
72 lines (69 loc) · 1.69 KB
/
selenium.groovy
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
/**
* This pipeline executes Selenium tests against Chrome and Firefox, all running in the same Pod but in separate containers
* and in parallel
*/
podTemplate(yaml: """
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven-firefox
image: maven:3.3.9-jdk-8-alpine
command: ['cat']
tty: true
- name: maven-chrome
image: maven:3.3.9-jdk-8-alpine
command: ['cat']
tty: true
- name: selenium-hub
image: selenium/hub:3.4.0
- name: selenium-chrome
image: selenium/node-chrome:3.4.0
env:
- name: HUB_PORT_4444_TCP_ADDR
value: localhost
- name: HUB_PORT_4444_TCP_PORT
value: 4444
- name: DISPLAY
value: :99.0
- name: SE_OPTS
value: -port 5556
- name: selenium-firefox
image: selenium/node-firefox:3.4.0
env:
- name: HUB_PORT_4444_TCP_ADDR
value: localhost
- name: HUB_PORT_4444_TCP_PORT
value: 4444
- name: DISPLAY
value: :98.0
- name: SE_OPTS
value: -port 5557
"""
) {
node(POD_LABEL) {
stage('Checkout') {
git 'https://github.com/carlossg/selenium-example.git'
parallel (
firefox: {
container('maven-firefox') {
stage('Test firefox') {
sh 'mvn -B clean test -Dselenium.browser=firefox -Dsurefire.rerunFailingTestsCount=5 -Dsleep=0'
}
}
},
chrome: {
container('maven-chrome') {
stage('Test chrome') {
sh 'mvn -B clean test -Dselenium.browser=chrome -Dsurefire.rerunFailingTestsCount=5 -Dsleep=0'
}
}
}
)
}
stage('Logs') {
containerLog('selenium-chrome')
containerLog('selenium-firefox')
}
}
}