-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
89 lines (77 loc) · 3.5 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
def pytest(unit){
try {
startBrowser(unit)
sh "export DISPLAY=:1.0 ; . .py_env/bin/activate && py.test -v -r fxE --junitxml results/${unit}.xml orcid/${unit}.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "PYTEST PROBLEM: $err_msg"
throw err
} finally {
junit 'results/*.xml'
sh 'rm -rf results/*.xml'
stopBrowser(unit)
}
}
def startBrowser(unit){
echo "Creating xvfb..."
sh "Xvfb :1 -screen 0 1024x758x16 -fbdir ${WORKSPACE}/xvfb & > /dev/null 2>&1 && echo \$! > /tmp/${unit}.pid"
sh "cat /tmp/${unit}.pid"
}
def stopBrowser(unit){
echo "Destroying xvfb..."
sh "XVFB_PID=\$(cat /tmp/${unit}.pid) ; kill \$XVFB_PID"
}
node {
properties([
buildDiscarder(
logRotator(artifactDaysToKeepStr: '5', artifactNumToKeepStr: '5', daysToKeepStr: '', numToKeepStr: '5')
),
parameters([
string(name: 'branch_to_build' , defaultValue: 'master' , description: 'Branch name to work on'),
string(name: 'test_server' , defaultValue: 'qa.orcid.org' , description: 'Base domain name to test'),
string(name: 'user_login' , defaultValue: '[email protected]' , description: 'Username'),
string(name: 'user_pass' , defaultValue: 'jeff2502test' , description: 'Password'),
string(name: 'orcid_id' , defaultValue: '0000-0003-2390-3547' , description: 'Latest orcid ID'),
string(name: 'search_value' , defaultValue: 'jeff2502' , description: 'Family name query format'),
string(name: 'client_secrets_file' , defaultValue: '/var/lib/jenkins/orcidclients.py' , description: 'Properties file with predefined secrets')
]),
[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false]
])
git url: 'https://github.com/ORCID/orcid-independent-tests.git', branch: params.branch_to_build
stage('Initialize'){
sh "rm -f orcid/properties.py"
writeFile file: 'testinputs.py', text: "test_server=\"$test_server\"\nsearchValue=\"$search_value\"\norcidId=\"$orcid_id\"\nuser_login=\"$user_login\"\nuser_pass=\"$user_pass\"\npassword=\"$user_pass\"\n"
sh "cat $client_secrets_file testinputs.py > orcid/properties.py"
sh "rm -rf .py_env results *.secret ${WORKSPACE}/xvfb && mkdir results ${WORKSPACE}/xvfb"
sh "virtualenv .py_env"
sh ". .py_env/bin/activate && pip2 install -q -r orcid/requirements.txt"
}
stage('TEST MEMBER 2.0 API POST UPDATE'){
try {
pytest 'test_member20_api_post_update'
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('TEST 2.0 API ALL ENDPOINTS') {
try {
pytest 'test_20api_all_endpoints'
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('TEST EXPECTED ERRORS'){
try {
pytest 'test_expected_errors'
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage ('Finalize'){
archive 'geckodriver.log'
deleteDir()
}
}