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