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