forked from ORCID/orcid-independent-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
155 lines (130 loc) · 6.14 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
154
155
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: 'ma_test_31052017' , description: 'Username'),
string(name: 'user_pass' , defaultValue: 'ma_test_31052017' , description: 'Password'),
string(name: 'orcid_id' , defaultValue: '0000-0002-6816-6010' , description: 'Latest orcid ID'),
string(name: 'search_value' , defaultValue: '31052017' , 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('Crate properties file'){
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\"\npassword=\"$user_pass\"\n"
sh "cat $client_secrets_file testinputs.py > orcid/properties.py"
}
stage('Prepare Environment'){
sh "rm -rf .py_env results"
sh "virtualenv .py_env"
sh "mkdir results"
sh ". .py_env/bin/activate && pip2 install -r orcid/requirements.txt"
}
stage('Clean OrcidiD'){
def cleanup_orcid_record = false
try {
timeout(time:20,unit:'SECONDS'){
cleanup_orcid_record = input message: 'Would you like to clean up orcid record before continue ?',
ok: 'Clean',
parameters: [booleanParam(defaultValue: false, description: '', name: 'Clean ?')]
}
} catch(err){
echo err.toString()
}
if (cleanup_orcid_record) {
echo "Removing activities from orcid record [$orcid_id]"
sh ". .py_env/bin/activate && pytest -v -r fEx orcid/api_read_delete.py"
} else {
echo "Continuing with existing record content."
}
}
stage('Run Test Public Read'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_public_api_read_search.xml orcid/test_public_api_read_search.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run Test 1.2 post'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_member12_api_post_update.xml orcid/test_member12_api_post_update.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run Test 2.0 post'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_member20_api_post_update.xml orcid/test_member20_api_post_update.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run Test Public Record'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_public_record.xml orcid/test_public_record.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run Test Private Record'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_private_record.xml orcid/test_private_record.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run Expected Errors Test'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_expected_errors.xml orcid/test_expected_errors.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run Limited Record Test'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_limited_record.xml orcid/test_limited_record.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run 1.2 All Endpoints'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_12api_all_endpoints.xml orcid/test_12api_all_endpoints.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run 2.0 All Endpoints'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_20api_all_endpoints.xml orcid/test_20api_all_endpoints.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
}
}
stage('Run Test scope methods'){
try {
sh ". .py_env/bin/activate && py.test --junitxml results/test_scope_methods.xml orcid/test_scope_methods.py"
} catch(Exception err) {
def err_msg = err.getMessage()
echo "Tests problem: $err_msg"
} finally {
junit 'results/*.xml'
deleteDir()
}
}
}