forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selenium.groovy
52 lines (49 loc) · 2.1 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
/**
* This pipeline executes Selenium tests against Chrome and Firefox, all running in the same Pod but in separate containers
* and in parallel
*/
podTemplate(label: 'maven-selenium', containers: [
containerTemplate(name: 'maven-firefox', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'maven-chrome', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'selenium-hub', image: 'selenium/hub:3.4.0'),
// because containers run in the same network space, we need to make sure there are no port conflicts
// we also need to adapt the selenium images because they were designed to work with the --link option
containerTemplate(name: 'selenium-chrome', image: 'selenium/node-chrome:3.4.0', envVars: [
containerEnvVar(key: 'HUB_PORT_4444_TCP_ADDR', value: 'localhost'),
containerEnvVar(key: 'HUB_PORT_4444_TCP_PORT', value: '4444'),
containerEnvVar(key: 'DISPLAY', value: ':99.0'),
containerEnvVar(key: 'SE_OPTS', value: '-port 5556'),
]),
containerTemplate(name: 'selenium-firefox', image: 'selenium/node-firefox:3.4.0', envVars: [
containerEnvVar(key: 'HUB_PORT_4444_TCP_ADDR', value: 'localhost'),
containerEnvVar(key: 'HUB_PORT_4444_TCP_PORT', value: '4444'),
containerEnvVar(key: 'DISPLAY', value: ':98.0'),
containerEnvVar(key: 'SE_OPTS', value: '-port 5557'),
])
]) {
node('maven-selenium') {
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')
}
}
}