-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
170 lines (148 loc) · 5.88 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
properties([
pipelineTriggers([
//cron('H/60 * * * *'),
[$class: 'GitHubPushTrigger'],
])
])
def configs = [
[
label: 'windows',
versions: ['py27', 'py33', 'py34', 'py35', 'py36'] //'py26',
]
]
def build(version, label) {
def repo_name = 'github_publish' //can be extracted from url.git
def repo_owner = 'umihai1' //can be extracted from url.git
def project_name = 'github_publish' //can be extracted from the project
try {
timeout(time: 30, unit: 'MINUTES') {
if (label.contains("windows")) {
def pythonPath = [
py26: "C:\\Python26\\python.exe",
py27: "C:\\Python27\\python.exe",
py33: "C:\\Python33\\python.exe",
py34: "C:\\Python34\\python.exe",
py35: "C:\\Python35\\python.exe",
py36: "C:\\Python36\\python.exe"
]
echo 'Check out scm...'
dir (repo_name){
checkout scm
}
echo 'Install Python Virtual Environment: ' + label + '-' + version
bat """
@echo on
rem wmic qfe
rem Prepare python virtual environment
@set PATH="C:\\Python27";"C:\\Python27\\Scripts";%PATH%
@set PYTHON="${pythonPath[version]}"
python --version
python -m virtualenv -p %PYTHON% .release_${version}
call .release_${version}\\Scripts\\activate
python --version
python -c "import platform, sys; major, minor, patch = platform.python_version_tuple(); print(str('py'+major+minor)); sys.exit(0) if str('py'+major+minor) == '${version}' else sys.exit(1)"
if not %errorlevel% == 0 exit 1
python -m pip --version
cd ${repo_name}
echo Install requirements....
python -m pip install -r requirements_develop.txt
echo Run tests with coverage
python -m coverage run -p test/run_all.py
echo Generate xml coverage report
rem python -m coverage xml -i
python -m pylint --rcfile .pylintrc github_publish >pylint.report.${version}
echo Copy .coverage for later processing
if not exist ..\\coverage mkdir ..\\coverage
xcopy /s /y .coverage.* ..\\coverage
if not exist ..\\test-reports mkdir ..\\test-reports
xcopy /s /y test-reports\\*.* ..\\test-reports
echo Copy pylint report for later processing
if not exist ..\\pylint mkdir ..\\pylint
xcopy /s /y pylint.* ..\\pylint
"""
} // end label.contains("windows")
//archiveArtifacts artifacts: repo_name + "/.coverage.*"
//archiveArtifacts artifacts: repo_name + "/pylint.report." + version
//archiveArtifacts artifacts: repo_name + '/test-reports/*.xml'
} // end timeout(time: 30, unit: 'MINUTES')
} // end timeout
catch(err) {
currentBuild.result = 'FAILURE'
throw err
}
finally {
echo 'Clean workspace...'
//cleanWs deleteDirs: true
}
}
def builders = [:]
for (config in configs) {
def label = config["label"]
def versions = config["versions"]
for (_version in versions) {
def version = _version
if (label.contains("windows")) {
def combinedName = "${label}-${version}"
builders[combinedName] = {
node(label) {
ws("jobs/${env.JOB_NAME}/ws"){
stage(combinedName) {
build(version, label)
}
}
}
}
}
}
}
parallel builders
node('windows') {
ws("jobs/${env.JOB_NAME}/ws"){
try{
stage('Reporting'){
echo 'Copy artifacts...'
echo 'Combine xml coverage'
bat """
@echo on
@set PATH="C:\\Python35";"C:\\Python35\\Scripts";%PATH%
@set PYTHON="C:\\Python35\\python.exe"
python --version
python -m pip install coverage
cd coverage
python -m coverage combine
python -m coverage xml -i
"""
echo '...CoberturaPublisher...'
step([$class: 'CoberturaPublisher',
autoUpdateHealth: false,
autoUpdateStability: false,
coberturaReportFile: 'coverage/coverage.xml',
failNoReports: false,
failUnhealthy: false,
failUnstable: false,
maxNumberOfBuilds: 0,
onlyStable: false,
sourceEncoding: 'ASCII',
zoomCoverageChart: true])
echo '...junit report...'
junit '/test-reports/*.xml'
echo '...WarningsPublisher...'
step([$class: 'WarningsPublisher',
parserConfigurations: [
[parserName: 'PYLint',
pattern: 'pylint/pylint.report.py36']
],
unstableTotalAll: '5000',
usePreviousBuildAsReference: true])
}
}
catch(err) {
currentBuild.result = 'FAILURE'
throw err
}
finally {
echo 'Clean workspace...'
cleanWs deleteDirs: true
}
}
}