-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
153 lines (150 loc) · 4.98 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
// Example Jenkins build file, you will need to update the repository location and authentication
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
retry(2)
timeout(time: 2, unit: 'HOURS')
gitLabConnection("${CONNECTION URL HERE}/${env.BRANCH_NAME}")
}
triggers {
cron('H H(1-5) * * *') // Run every morning between 1 and 6
pollSCM('H/5 * * * *') // Poll every 5 minutes
gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All') // Gitlab doesn't seem to be working yet.
}
environment {
NO_PROXY='127.0.0.1,localhost'
no_proxy='127.0.0.1,localhost'
}
stages {
stage('clone') {
steps {
sh "printenv"
checkout([
$class: 'GitSCM',
branches: [[name: "origin/${env.BRANCH_NAME}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false]],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'gitlab_project_demodocus_framework',
url: "${REPOSITORY URL HERE}"]]
])
}
}
stage('build') {
steps {
sh script: ''' #!/bin/bash
source /opt/rh/rh-python36/enable
python -m venv ENV
source ENV/bin/activate
python -V
pip install --upgrade pip
pip install -Ur requirements.txt
echo "Pulling chromedriver version -- $(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_`expr substr "$(google-chrome --version)" 15 9`)"
wget "https://chromedriver.storage.googleapis.com/$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_`expr substr "$(google-chrome --version)" 15 9`)/chromedriver_linux64.zip"
unzip -d ENV/bin chromedriver_linux64.zip
'''
}
}
stage('test_dom_manipulations') {
steps {
runShortTest('demodocusfw/tests/dom_manipulations.py')
}
}
stage('test_compare') {
steps {
runShortTest('demodocusfw/tests/compare.py')
}
}
stage('test_reachable') {
steps {
runShortTest('demodocusfw/tests/reachable.py')
}
}
stage('test_selenium_integration') {
steps {
runShortTest('demodocusfw/tests/selenium_integration.py')
}
}
stage('test_web_access_chrome') {
steps {
runShortTest('demodocusfw/tests/test_web_access_chrome.py')
}
}
stage('test_event_tracking') {
steps {
runShortTest('demodocusfw/tests/event_tracking.py')
}
}
stage('test_animation') {
steps {
runShortTest('demodocusfw/tests/animation.py')
}
}
stage('test_crawler') {
steps {
runShortTest('demodocusfw/tests/crawler.py')
}
}
stage('test_crawl_graph') {
steps {
runShortTest('demodocusfw/tests/crawler.py')
}
}
stage('test_reduced_crawl') {
steps {
runShortTest('demodocusfw/tests/reduced_crawl.py')
}
}
stage('test_analysis') {
steps {
runShortTest('demodocusfw/tests/analysis.py')
}
}
stage('test_keyboard_eval') {
steps {
runShortTest('demodocusfw/tests/keyboard_eval.py')
}
}
}
post { // Make to always try and clean the workspace
always {
echo 'Finished build'
cleanWs()
}
success {
echo 'Successfully cleaned workspace.'
}
failure {
echo 'Failed to clean workspace.'
}
}
}
// we need to ensure the env variables are always correct.
// NOTE: function not used, but built for use in future
// dev branches.
def runFullTest(testName) {
// Slight trick, since it uses '$' as a variable,
// we need to escape that symbol within the string
sh """#!/bin/bash
export PATH=\$PATH:ENV/bin
export PYTHONPATH=src/:\$PYTHONPATH
export DEM_RUN_EXTENDED=True
source ENV/bin/activate
python -m unittest ${testName}
"""
}
def runShortTest(testName) {
sh """#!/bin/bash
export PATH=\$PATH:ENV/bin
export PYTHONPATH=src/:\$PYTHONPATH
DEM_RUN_EXTENDED=False
source ENV/bin/activate
python -m unittest ${testName}
"""
}