-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile_backfor_seleniumhubwithNetwork
66 lines (54 loc) · 2.29 KB
/
Jenkinsfile_backfor_seleniumhubwithNetwork
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
def network='jenkins-${BUILD_NUMBER}'
def seleniumHub='selenium-hub-${BUILD_NUMBER}'
def chrome='chrome-${BUILD_NUMBER}'
def firefox='firefox-${BUILD_NUMBER}'
def containertest='conatinertest-${BUILD_NUMBER}'
pipeline {
agent {
any {
image 'maven:3-alpine'
args '-v $HOME/.m2:/root/.m2'
}
}
stages{
stage('Setting Up Selenium Grid') {
steps{
sh "docker network create ${network}"
sh "docker run -d -p 4444:4444 --name ${seleniumHub} --network ${network} selenium/hub"
sh "docker run -d -e HUB_PORT_4444_TCP_ADDR=${seleniumHub} -e HUB_PORT_4444_TCP_PORT=4444 --network ${network} --name ${chrome} -p 5900:32768 selenium/node-chrome-debug"
sh "docker run -d -e HUB_PORT_4444_TCP_ADDR=${seleniumHub} -e HUB_PORT_4444_TCP_PORT=4444 --network ${network} --name ${firefox} -p 5901:32769 selenium/node-firefox-debug"
}
}
stage('Build Jar') {
steps {
sh 'mvn clean package -DskipTests'
}
}
stage('Build Image') {
steps {
script {
// vinsdocker/containertest => organization/application - it could be anything
app = docker.build("vagrant/containertest")
sh "pwd"
}
}
}
stage('Run Test') {
steps{
// a directory 'search' is created for container test-output
sh "docker run --rm -e SELENIUM_HUB=${seleniumHub} -e BROWSER=chrome -e MODULE=runner.Start -v ${WORKSPACE}/AutomationPipeline:/usr/share/suman/test-output --network ${network} vagrant/containertest"
//archive all the files under 'search' directory
archiveArtifacts artifacts: 'target/**', fingerprint: true
}
}
stage('Tearing Down Selenium Grid') {
steps {
//remove all the containers and volumes
sh "docker rm -vf ${chrome}"
sh "docker rm -vf ${firefox}"
sh "docker rm -vf ${seleniumHub}"
sh "docker network rm ${network}"
}
}
}
}