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