##// END OF EJS Templates
jenkinsfile: only keep the artifacts (test result xml files) of the last 10 builds
domruf -
r6850:58713c2e default
parent child Browse files
Show More
@@ -1,206 +1,212 b''
1 1 def createvirtualenv = ''
2 2 def activatevirtualenv = ''
3 3
4 4 node {
5 properties([[$class: 'BuildDiscarderProperty',
6 strategy: [$class: 'LogRotator',
7 artifactDaysToKeepStr: '',
8 artifactNumToKeepStr: '10',
9 daysToKeepStr: '',
10 numToKeepStr: '']]]);
5 11 if (isUnix()) {
6 12 createvirtualenv = 'rm -r $JENKINS_HOME/venv/$JOB_NAME || true && virtualenv $JENKINS_HOME/venv/$JOB_NAME'
7 13 activatevirtualenv = '. $JENKINS_HOME/venv/$JOB_NAME/bin/activate'
8 14 } else {
9 15 createvirtualenv = 'rmdir /s /q %JENKINS_HOME%\\venv\\%JOB_NAME% || true && virtualenv %JENKINS_HOME%\\venv\\%JOB_NAME%'
10 16 activatevirtualenv = 'call %JENKINS_HOME%\\venv\\%JOB_NAME%\\Scripts\\activate.bat'
11 17 }
12 18
13 19 stage('checkout') {
14 20 checkout scm
15 21 if (isUnix()) {
16 22 sh 'hg --config extensions.purge= purge --all'
17 23 } else {
18 24 bat 'hg --config extensions.purge= purge --all'
19 25 }
20 26 }
21 27 stage('virtual env') {
22 28 def virtualenvscript = """$createvirtualenv
23 29 $activatevirtualenv
24 30 python -m pip install --upgrade pip
25 31 pip install --upgrade setuptools
26 32 pip install --upgrade pylint
27 33 pip install --upgrade pytest-cov
28 34 """
29 35 if (isUnix()) {
30 36 virtualenvscript += """
31 37 pip install --upgrade python-ldap
32 38 pip install --upgrade python-pam
33 39 """
34 40 sh virtualenvscript
35 41 } else {
36 42 bat virtualenvscript
37 43 }
38 44 }
39 45 stage('setup') {
40 46 def virtualenvscript = """$activatevirtualenv
41 47 pip install --upgrade -e .
42 48 pip install -r dev_requirements.txt
43 49 python setup.py compile_catalog
44 50 """
45 51 if (isUnix()) {
46 52 sh virtualenvscript
47 53 } else {
48 54 bat virtualenvscript
49 55 }
50 56 stash name: 'kallithea', useDefaultExcludes: false
51 57 }
52 58 stage('pylint') {
53 59 sh script: """$activatevirtualenv
54 60 pylint -j 0 --disable=C -f parseable kallithea > pylint.out
55 61 """, returnStatus: true
56 62 archiveArtifacts 'pylint.out'
57 63 try {
58 64 step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'PyLint', pattern: 'pylint.out']], unHealthy: ''])
59 65 } catch (java.lang.IllegalArgumentException exc) {
60 66 echo "You need to install the 'Warnings Plug-in' to display the pylint report."
61 67 currentBuild.result = 'UNSTABLE'
62 68 echo "Caught: ${exc}"
63 69 }
64 70 }
65 71 }
66 72
67 73 def pytests = [:]
68 74 pytests['sqlite'] = {
69 75 node {
70 76 ws {
71 77 deleteDir()
72 78 unstash name: 'kallithea'
73 79 if (isUnix()) {
74 80 sh script: """$activatevirtualenv
75 81 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
76 82 """, returnStatus: true
77 83 } else {
78 84 bat script: """$activatevirtualenv
79 85 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
80 86 """, returnStatus: true
81 87 }
82 88 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1SQLITE./g" pytest_sqlite.xml'
83 89 archiveArtifacts 'pytest_sqlite.xml'
84 90 junit 'pytest_sqlite.xml'
85 91 writeFile(file: '.coverage.sqlite', text: readFile('.coverage'))
86 92 stash name: 'coverage.sqlite', includes: '.coverage.sqlite'
87 93 }
88 94 }
89 95 }
90 96
91 97 pytests['de'] = {
92 98 node {
93 99 if (isUnix()) {
94 100 ws {
95 101 deleteDir()
96 102 unstash name: 'kallithea'
97 103 withEnv(['LANG=de_DE.UTF-8',
98 104 'LANGUAGE=de',
99 105 'LC_ADDRESS=de_DE.UTF-8',
100 106 'LC_IDENTIFICATION=de_DE.UTF-8',
101 107 'LC_MEASUREMENT=de_DE.UTF-8',
102 108 'LC_MONETARY=de_DE.UTF-8',
103 109 'LC_NAME=de_DE.UTF-8',
104 110 'LC_NUMERIC=de_DE.UTF-8',
105 111 'LC_PAPER=de_DE.UTF-8',
106 112 'LC_TELEPHONE=de_DE.UTF-8',
107 113 'LC_TIME=de_DE.UTF-8',
108 114 ]) {
109 115 sh script: """$activatevirtualenv
110 116 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea
111 117 """, returnStatus: true
112 118 }
113 119 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1DE./g" pytest_de.xml'
114 120 archiveArtifacts 'pytest_de.xml'
115 121 junit 'pytest_de.xml'
116 122 writeFile(file: '.coverage.de', text: readFile('.coverage'))
117 123 stash name: 'coverage.de', includes: '.coverage.de'
118 124 }
119 125 }
120 126 }
121 127 }
122 128 pytests['mysql'] = {
123 129 node {
124 130 if (isUnix()) {
125 131 ws {
126 132 deleteDir()
127 133 unstash name: 'kallithea'
128 134 sh """$activatevirtualenv
129 135 pip install --upgrade MySQL-python
130 136 """
131 137 withEnv(['TEST_DB=mysql://kallithea:kallithea@jenkins_mysql/kallithea_test?charset=utf8']) {
132 138 if (isUnix()) {
133 139 sh script: """$activatevirtualenv
134 140 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea
135 141 """, returnStatus: true
136 142 } else {
137 143 bat script: """$activatevirtualenv
138 144 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea
139 145 """, returnStatus: true
140 146 }
141 147 }
142 148 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1MYSQL./g" pytest_mysql.xml'
143 149 archiveArtifacts 'pytest_mysql.xml'
144 150 junit 'pytest_mysql.xml'
145 151 writeFile(file: '.coverage.mysql', text: readFile('.coverage'))
146 152 stash name: 'coverage.mysql', includes: '.coverage.mysql'
147 153 }
148 154 }
149 155 }
150 156 }
151 157 pytests['postgresql'] = {
152 158 node {
153 159 if (isUnix()) {
154 160 ws {
155 161 deleteDir()
156 162 unstash name: 'kallithea'
157 163 sh """$activatevirtualenv
158 164 pip install --upgrade psycopg2
159 165 """
160 166 withEnv(['TEST_DB=postgresql://kallithea:kallithea@jenkins_postgresql/kallithea_test']) {
161 167 if (isUnix()) {
162 168 sh script: """$activatevirtualenv
163 169 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea
164 170 """, returnStatus: true
165 171 } else {
166 172 bat script: """$activatevirtualenv
167 173 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea
168 174 """, returnStatus: true
169 175 }
170 176 }
171 177 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1POSTGRES./g" pytest_postgresql.xml'
172 178 archiveArtifacts 'pytest_postgresql.xml'
173 179 junit 'pytest_postgresql.xml'
174 180 writeFile(file: '.coverage.postgresql', text: readFile('.coverage'))
175 181 stash name: 'coverage.postgresql', includes: '.coverage.postgresql'
176 182 }
177 183 }
178 184 }
179 185 }
180 186 stage('Tests') {
181 187 parallel pytests
182 188 node {
183 189 unstash 'coverage.sqlite'
184 190 unstash 'coverage.de'
185 191 unstash 'coverage.mysql'
186 192 unstash 'coverage.postgresql'
187 193 if (isUnix()) {
188 194 sh script: """$activatevirtualenv
189 195 coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql
190 196 coverage xml
191 197 """, returnStatus: true
192 198 } else {
193 199 bat script: """$activatevirtualenv
194 200 coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql
195 201 coverage xml
196 202 """, returnStatus: true
197 203 }
198 204 try {
199 205 step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false])
200 206 } catch (java.lang.IllegalArgumentException exc) {
201 207 echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report."
202 208 currentBuild.result = 'UNSTABLE'
203 209 echo "Caught: ${exc}"
204 210 }
205 211 }
206 212 }
General Comments 0
You need to be logged in to leave comments. Login now